Detecting which application currently has focus...

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
 
M

Mattias Sjögren

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top