Take the tour ×  How could I detect when any application loses
focus? Is there any system hooks to use? I want to pick up when
ever a new application is in focus, or when one is lost. Even
having the "current" HWND of the user would be good.  I am using
C#, however, its all win api stuff I am sure... so any info
would be great.  share|improve this question Update I know I can
use GetForegroundWindow() to get the current window HWND, I just
want to subscribe to an event that will notify me of it
changing. –  Mike Curry Nov 12 '08 at 21:21 add comment  1
Answer  Use SetWindowsHookEx to set either a WH_CALLWNDPROC or
WH_CALLWNDPROCRET global hook, and look for WM_SETFOCUS and or
WM_KILLFOCUS messages.  share|improve this answer Have an
example? –  Mike Curry Dec 6 '08 at 3:37 add comment  Your
Answer