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 secondary monitor when a taskbar icon flashes, an error/notification pops up, etc.
As far as I can tell, the way to do detect these events is using message hooks, as described here: http://msdn.microsoft.com/en-us/library/ms632589%28v=vs.85%29.aspx
I was even lucky enough to find an example that accesses the SetWindowsHookEx function from Python. (This particular example uses mouse signals, but I can just change the constants to listen for different messages). http://www.python-forum.org/pythonforum/viewtopic.php?f=2&t=11154
However, the above example does not work. The callback function is never called, regardless of my mouse clicks, and a middle mouse click does not cause the program to exit.
The example is from 2009 (pre windows 7?),though I don't know if that's the issue.
So, my question is, can anybody 1. find out why the code works, or 2. tell me another way to achieve what I'm doing (preferably in Python, though I'll go to other languages if necesarry).
Edit: Is it possible to do what I'm wanting with WMI? I don't know WMI well, but I know that it does have very good Python interface.