I am trying to follow this answer and i have reached the point where a should call
GetGUIThreadInfo()
but i cannot find that in the pywin32 docomentation i am using.
What i have done so far is
import win32api
import win32gui
import win32process
test1 = win32gui.FindWindowEx(0, 0, 0, "notepad")
(test1tid, test1pid) = win32process.GetWindowThreadProcessId(test1)
test1hwndFocus = win32process.GetGUIThreadInfo(test1tid)
but the last line is compleatly made up as i cannot find the right way to call the function.
Update1:
Think i made some progress but now my struct just returns 0 when i expect some hwnd... so maybe my struct is not writen to, i think this could be because of the types in my struct, but how do i find the right types?
import win32api
import win32gui
import win32process
import ctypes
class RECT(ctypes.Structure):
_fields_ = [
("left", ctypes.c_ulong),
("top", ctypes.c_ulong),
("right", ctypes.c_ulong),
("bottom", ctypes.c_ulong)
]
class GUITHREADINFO(ctypes.Structure):
_fields_ = [
("cbSize", ctypes.c_ulong),
("flags", ctypes.c_ulong),
("hwndActive", ctypes.c_ulong),
("hwndFocus", ctypes.c_ulong),
("hwndCapture", ctypes.c_ulong),
("hwndMenuOwner", ctypes.c_ulong),
("hwndMoveSize", ctypes.c_ulong),
("hwndCaret", ctypes.c_ulong),
("rcCaret", RECT)
]
guiThreadInfoStruct = GUITHREADINFO()
ctypes.sizeof(gtitest)
test1 = win32gui.FindWindowEx(0, 0, 0, "notepad")
(test1tid, test1pid) = win32process.GetWindowThreadProcessId(test1)
ctypes.windll.user32.GetGUIThreadInfo(test1tid, guiThreadInfoStruct)
print (guiThreadInfoStruct.hwndFocus)
Update2:
I found the types here
update3:
If anyone wanna see what i used this for go look here