Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2007

Tip: Looking for answers? Try searching our database.

Active process on windows

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rotsey - 26 Aug 2007 08:43 GMT
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
Morten Wennevik [C# MVP] - 26 Aug 2007 13:11 GMT
> Hi,
>
[quoted text clipped - 9 lines]
>
> rotsey

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

Signature

Happy coding!
Morten Wennevik [C# MVP]

Rotsey - 27 Aug 2007 03:48 GMT
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.

>> Hi,
>>
[quoted text clipped - 11 lines]
>
> You can pass it as an argument when launching the application.
Morten Wennevik [C# MVP] - 27 Aug 2007 16:55 GMT
> What do you mean?
>
[quoted text clipped - 22 lines]
>> 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.

Signature

Happy coding!
Morten Wennevik [C# MVP]


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.