Active process on windows

  • Thread starter Thread starter Rotsey
  • Start date Start date
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
 
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.
 
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.
 
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.
 
Back
Top