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.
Well the handle being returned from GetForegroundWindow is actually a handle to the Window and not the parent process. You can get the Thread process Id of the Window with ctypes.windll.user32.GetWindowThreadProcessId(handle) and from there you may be able to get the spawning process handle and then call GetProcessId on that handle.
Well the handle being returned from GetForegroundWindow is actually a handle to the Window and not the parent process. You can get the Thread process Id of the Window with ctypes.windll.user32.GetWindowThreadProcessId(handle) and from there you may be able to get the spawning process handle and then call GetProcessId on that handle.
Well the handle being returned from GetForegroundWindow is actually a handle to the Window and not the parent process. You can get the Thread process Id of the Window with ctypes.windll.user32.GetWindowThreadProcessId(handle) and from there you may be able to get the spawning process handle and then call GetProcessId on that handle.