Check if active
Check if active
Is there a way to check if the program is the active window? And also too for graphics mode?
-
- Posts: 862
- Joined: May 05, 2015 5:35
- Location: Germany
Re: Check if active
Something like this?
Code: Select all
#Include "windows.bi"
#Include "win\psapi.bi"
Dim As HANDLE processhandle, hwnd
Dim As ULong PID
Dim As ZString*MAX_PATH filename
hwnd = GetActiveWindow()
If hwnd Then
GetWindowThreadProcessId(hwnd, @PID)
processHandle = OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, FALSE, PID)
GetModuleFileNameEx(processHandle, NULL, filename, MAX_PATH)
CloseHandle(processHandle)
If filename = Command(0) Then
Print "active"
Else
Print "no"
EndIf
Else
Print "no active window"
EndIf
Sleep
Re: Check if active
Many thanks
Re: Check if active
On Windows, check the difference between GetActiveWindow, GetForegroundWindow and GetFocus.