Capture Window Focus Change
-
Hey Guys, If I want to know the process ID of the window that currently has focus then I call GetForegroundProcessID().... I am trying to think of the best way to capture a change in the focused window. I could create a systemhook on WH_CALLWNDPROC and search for a WM_ACTIVATE or WM_FOCUS message and check the process to whom it's being sent. or I could poll every x seconds and check who the window in focus is. Is there any option that I am not thinking of that won't hurt my perfomance like system hooks will?
-
Hey Guys, If I want to know the process ID of the window that currently has focus then I call GetForegroundProcessID().... I am trying to think of the best way to capture a change in the focused window. I could create a systemhook on WH_CALLWNDPROC and search for a WM_ACTIVATE or WM_FOCUS message and check the process to whom it's being sent. or I could poll every x seconds and check who the window in focus is. Is there any option that I am not thinking of that won't hurt my perfomance like system hooks will?
If you're going to use a system hook, a
WH_SHELL
hook (look for aHSHELL_WINDOWACTIVATED
notification) might be cheaper performance-wise? Otherwise, your other solution seems a pretty cheap (performance-wise) alternative. I don't know of other alternatives myself :-(