I want to write a program:
- click a window(some other program, like firefox, explorer..)
- get this window’s HWND
- do something to that window
My method is using PeekMessage to get event, but looks like PeekMessage only peek the message send from my program.
So how can I add a hook to all the other windows, or monitor global events?
SetWindowsHookEx, with theWH_MOUSEor possiblyWH_MOUSE_LLflag. MFC itself doesn’t really have much to do with this, at least to my recollection (though, behind the scenes, MFC can/does install a hook, or maybe even more than one, itself).