I am trying to design my game to run alongside another program that I did not write and the source and author are not available. The information I need from that program is in the title bar. So, I was thinking that every second or so, I loop all the available windows looking for that one, and parsing data from the title text. Works in theory, not in practice.
Here is what I have so far. It is supposed to loop all the windows after the current, and then all the ones before the current one, and run CheckWindowName() on the window's title text. It is crashing while running
Result = CALL DLL(DLL_User32,"GetNextWindow",Handle,2).
Any Suggestions?
GLOBAL DLL_User32 AS INTEGER : DLL_User32 = FIND FREE DLL() : LOAD DLL "User32.dll" ,DLL_User32
GLOBAL DLL_Kernel32 AS INTEGER : DLL_Kernel32 = FIND FREE DLL() : LOAD DLL "Kernel32.dll" ,DLL_Kernel32
GLOBAL DLL_WinLock AS INTEGER : DLL_WinLock = FIND FREE DLL() : LOAD DLL "WinLockDll.dll",DLL_WinLock
GLOBAL DLL_GDI32 AS INTEGER : DLL_GDI32 = FIND FREE DLL() : LOAD DLL "GDI32.dll" ,DLL_GDI32
Update_Navi()
wait key
end
function Update_Navi()
Local hwnd,resulthWnd as dword
hwnd = GetForegroundWindow()
resulthWnd = GetNextWindow(hwnd)
while resulthWnd
CheckWindowName(GetWindowTitle(resulthWnd))
resulthWnd = GetNextWindow(resulthWnd)
endwhile
resulthWnd = GetPreviousWindow(hwnd)
while resulthWnd
CheckWindowName(GetWindowTitle(resulthWnd))
resulthWnd = GetPreviousWindow(resulthWnd)
endwhile
Endfunction
FUNCTION GetNextWindow(Handle) : ` Get the Next Window in zOrder
Result = CALL DLL(DLL_User32,"GetNextWindow",Handle,2)
ENDFUNCTION Result
FUNCTION GetWindowTitle(Handle)
Title as string
Title = space$(256)
CALL DLL DLL_User32,"GetWindowTextA",Handle,Title,Len(Title)
Title = trim$(Title)
ENDFUNCTION Title
FUNCTION GetPreviousWindow(Handle) : ` Get the Previous Window in zOrder
Result = CALL DLL(DLL_User32,"GetNextWindow",Handle,3)
ENDFUNCTION Result
FUNCTION GetForegroundWindow() : ` Get the Handle for the Active Window
hwnd = CALL DLL(DLL_User32,"GetForegroundWindow")
ENDFUNCTION hwnd
function CheckWindowName(f$)
print f$
endfunction