Python Ctypes: Setwindowshookex Callback Function Never Called
I'm trying to write a program in Python that is aware of when alert boxes/dialogues are shown. It's dealing with multiple monitors, and I want it to display a visualization on the
Solution 1:
With the exception of WH_KEYBOARD_LL and WH_MOUSE_LL, the Windows hooks must be implemented in a DLL that Windows injects into each application process. Therefore, you can't simply implement a callback in your program and expect Windows to run it.
I can think of two ways to solve this problem:
Write a DLL in C or C++ that implements the hook procedure and notifies your main program through some form of inter-process communication. Then load this DLL in your main program and pass its module handle and the hook procedure implemented in that DLL to SetWindowsHookEx.
The SetWinEventHook function may give you what you want. WinEvent hooks can be implemented in your main program.
Post a Comment for "Python Ctypes: Setwindowshookex Callback Function Never Called"