Detecting which application currently has focus...

  • Thread starter Thread starter Paul Aspinall
  • Start date Start date
P

Paul Aspinall

Hi
I am trying to write a piece of code, which will tell me which application
currently has focus / which the user is currently working on. ie. if the
user is currently in IE, or Word etc....

How can I find this in .NET?

Thanks
 
How can I find this in .NET?

Call the GetForegroundWindow Win32 API to get the window handle for
the foreground window. You can then for example call
GetWindowThreadProcessId to get the process that created the window.
And then use the process ID to retrieve any information you need about
the application.


Mattias
 
Back
Top