tags:

views:

804

answers:

2

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.

+3  A: 

Use SetWindowsHookEx to set either a WH_CALLWNDPROC or WH_CALLWNDPROCRET global hook, and look for WM_SETFOCUS and or WM_KILLFOCUS messages.

cookre
Have an example?
Mike Curry
A: 

Anyone have a C++ example of this?

Mike Curry