Event fired when forground window changes??

  • Thread starter Thread starter Lex
  • Start date Start date
L

Lex

I want to write an app in C# that keeps track of when the foreground
window in the OS changes. Is there an event that I can "susbscribe"
to for this? Or am I stuck polling using the GetForegroundWindow()
method?

Regards
 
Lex,

You can probably set up a system-wide hook through a call to the
SetWindowsHookEx function in the Win32 API. You should be able to set up a
hook of type WH_CALLWNDPROC, and then check for messages that are posted to
windows when they get or lose focus.

Hope this helps.
 
Back
Top