0
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?

zyl
  • 197
  • 1
  • 2
  • 12

1 Answers1

0

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.

Zeus
  • 3,703
  • 3
  • 7
  • 20
  • Hi, does the answer solve your issue? Please feel free to let me know if you have any issue and also accept it if it does help. – Zeus May 04 '21 at 06:51