hwnd = win32gui.FindWindowEx(None, None, "TXGuiFoundation", None)
I want to hook a window and receive its messages.
got the hwnd variable
(type(hwnd)
is int), but how to convert it into PyCwnd
and use PyCwnd.HookMessage
?
PyCwnd
is a base window class. Encapsulates an MFC CWnd
class.
So you can refer to CWnd::FromHandle:
Returns a pointer to a CWnd object when given a handle to a window. If a CWnd object is not attached to the handle, a temporary CWnd object is created and attached.
Also you can use win32ui.CreateWindowFromHandle
, you can refer to this thread.