Active process on windows

R

Rotsey

Hi,

I am writing app that I want to be able to hit a shortcut
key (windows wide) and have it all launch my app and then
be able to get the name of the process that was active when
the key was pressed.

Is this possible and how?

I know I can assign a shortcut key to the app but how do
I get the active process name?

rotsey
 
M

Morten Wennevik [C# MVP]

Hi,

I am writing app that I want to be able to hit a shortcut
key (windows wide) and have it all launch my app and then
be able to get the name of the process that was active when
the key was pressed.

Is this possible and how?

I know I can assign a shortcut key to the app but how do
I get the active process name?

rotsey

You can pass it as an argument when launching the application.
 
R

Rotsey

What do you mean?

I do not know what was the active process when I press the shortcut key.

Not my app being the active process the active proces before I
press the key.
 
M

Morten Wennevik [C# MVP]

What do you mean?

I do not know what was the active process when I press the shortcut key.

Not my app being the active process the active proces before I
press the key.

Morten Wennevik said:
You can pass it as an argument when launching the application.

Ok, I think I understand now. You have, say, notepad focused and open your own application using a windows shortcut key combination. You could try to prevent your application taking focus, and when launched, get the focused window. There may be better ways, but you can always use pinvoke on user32.dll and call GetTopWindow. Not sure where you would go from there to get the process information, but GetWindowThreadProcessId might work.
 

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