I know that with GetForegroundWindow I can get the current active window handle, but now i want to detect when the active window (of any application) changes (become active) . the first solution that comes to my mind is
- save the current value (handle) returned by the GetForegroundWindow function.
- using the timer component again check the value returned by GetForegroundWindow and compare it with the old value.
I am wondering if there is a better way to do this, perhaps using a Windows message or something else.
source share