Is it possible to determine when window focus changes at the system level? I'm writing a time-tracking application, and I'd like to be able to listen for application switching (so that I can begin logging time in a given application). I've poked around the Process class for a good hour here, and while I learned quite a few useful things, I didn't find what I was looking for. I suspect I'll need to use hooks, but it's difficult finding clear documentation on the process, let alone documentation specific to what I'm asking.
Asked
Active
Viewed 1,092 times
1 Answers
3
See SetWindowHooksEx.
Good article, "Windows Hooks in the .NET Framework":
http://msdn.microsoft.com/en-us/magazine/cc188966.aspx

Corey Trager
- 22,649
- 18
- 83
- 121
-
this is good, and very useful, but there are some holes in his article that I wish were filled--namely the implementation of the GetClassName() and GetWindowText() Win32 functions. If you can fill in some of those holes, I'd be grateful. – Brian Warshaw Jul 06 '09 at 13:47