By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,501 Members | 1,678 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,501 IT Pros & Developers. It's quick & easy.

Active process on windows

P: n/a
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
Aug 26 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Sun, 26 Aug 2007 09:43:35 +0200, Rotsey <ma***********@RemoveThis.optusnet.com.auwrote:
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.

--
Happy coding!
Morten Wennevik [C# MVP]
Aug 26 '07 #2

P: n/a
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 [C# MVP]" <Mo************@hotmail.comwrote in message
news:op.txn1g8k8dj93y5@ubuan...
On Sun, 26 Aug 2007 09:43:35 +0200, Rotsey
<ma***********@RemoveThis.optusnet.com.auwrote:
>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.

--
Happy coding!
Morten Wennevik [C# MVP]

Aug 27 '07 #3

P: n/a
On Mon, 27 Aug 2007 04:48:22 +0200, Rotsey <ma***********@RemoveThis.optusnet.com.auwrote:
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 [C# MVP]" <Mo************@hotmail.comwrote in message
news:op.txn1g8k8dj93y5@ubuan...
>On Sun, 26 Aug 2007 09:43:35 +0200, Rotsey
<ma***********@RemoveThis.optusnet.com.auwrote:
>>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.

--
Happy coding!
Morten Wennevik [C# MVP]


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.

--
Happy coding!
Morten Wennevik [C# MVP]
Aug 27 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.