api_GetWindowText
Blitz3D Forums/Blitz3D Programming/api_GetWindowText
| ||
hello, I need your help, I'm trying to run this routine to display the names of the open windows on the desktop .... everything is in decls, but the program does not display anything!! I not understand, thank you for your help Const GW_HWNDFIRST = 0 Const GW_HWNDLAST = 1 Const GW_HWNDNEXT = 2 Const GW_HWNDPREV = 3 Const GW_OWNER = 4 Const GW_Child = 5 EnumWindows() WaitKey() End Function EnumWindows() Local hwnd_first = api_GetWindow(GetActiveWindow(),GW_HWNDFIRST) Local hwnd_temp = hwnd_first Repeat ; Nächstes Fenster hwnd_temp = api_GetWindow(hwnd_temp,GW_HWNDNEXT) ;Name Herausfinden bank_temp = CreateBank(255) sdf=api_GetWindowText(hwnd_temp,bank_temp,255) Local pos%=0,name$="" Repeat byte=PeekByte(bank_temp,pos) pos=pos+1 If byte=0 Then Exit name$=name$+Chr(byte) Forever If name$ <> "" Then Print hwnd_temp + ": "+name$ FreeBank bank_temp Until hwnd_temp =0 End Function |
| ||
Using DebugLog can help to identify what's going on in your program. Using the user32.decls this seems to run just fine for me... Const GW_HWNDFIRST = 0 Const GW_HWNDLAST = 1 Const GW_HWNDNEXT = 2 Const GW_HWNDPREV = 3 Const GW_OWNER = 4 Const GW_Child = 5 EnumWindows() WaitKey() End Function EnumWindows() Local hwnd_first = api_GetWindow(api_GetActiveWindow(),GW_HWNDFIRST) Local hwnd_temp = hwnd_first Local pos%=0 Local name$="" Repeat ; Nächstes Fenster hwnd_temp = api_GetWindow(hwnd_temp,GW_HWNDNEXT) DebugLog("WindowHandle="+Str(hwnd_temp)) ;Name Herausfinden bank_temp = CreateBank(255) sdf=api_GetWindowText(hwnd_temp,bank_temp,255) DebugLog("Text Result="+Str(sdf)) pos%=0 name$="" Repeat byte=PeekByte(bank_temp,pos) If (Not(byte)) DebugLog("Terminator Character at "+Str(pos)) Exit End If name$=name$+Chr(byte) pos=pos+1 Forever If (name$ <> "") DebugLog("Name "+name$) Print hwnd_temp + ": "+name$ End If FreeBank bank_temp Until (Not(hwnd_temp)) End Function Last edited 2012 |
| ||
I think you have a wrong decls declaration mostly, the string are passed as "string" when they should be pointers so, check if you have this in your decls api_GetWindowText% (hwnd%, lpString$, cch%) : "GetWindowTextA" then change the "lpString$" to "lpString* api_GetWindowText% (hwnd%, lpString*, cch%) : "GetWindowTextA" then it should work, and you'll be able to pass your bank as pointer. |