- Thread Author
- #1
hi I am trying to get PID from the foreground window, but this doesn't work because I am passing the wrong kind of handle to the function. This is under python.
How do I fix this?
thx!
How do I fix this?
thx!
Code:
import ctypes
import time
time.sleep(2)
handle = ctypes.windll.user32.GetForegroundWindow()
print(handle)
PID = ctypes.windll.kernel32.GetProcessId(handle)
print (PID)