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

How to get the Process the Active Proces?

P: n/a
Hi,

In my VB.NET-application I need to get the Process that is currently active
on the screen of the user. I need it to get back to that application after
that I brought mine to the front...

for exemple: user types in Word...
my application triggers an event, has to come to the foreground (when it is
minimzed)
immediately after that the Word-process has to be set again to the front so
the user can continu typing in word (and not in my application).

I don't think Process.GetCurrentProcess is the good answer, because that
points always to my VB.NET-application.

Thanks a lot in advance,

Pieter
Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Get the top window. There are a number of ways to do it. I am looking at an
MSDN article entitled 'Windows' from 'Windows Management' and they have
calls that can get a handle to the top window and calls that can bring a
window to the top. Two calls:

GetTopWindow
BringWIndowToTop

should do it. (No, I haven't doen this in windows but I have in other GUI
OSes.

"DraguVaso" wrote:
Hi,

In my VB.NET-application I need to get the Process that is currently active
on the screen of the user. I need it to get back to that application after
that I brought mine to the front...

for exemple: user types in Word...
my application triggers an event, has to come to the foreground (when it is
minimzed)
immediately after that the Word-process has to be set again to the front so
the user can continu typing in word (and not in my application).

I don't think Process.GetCurrentProcess is the good answer, because that
points always to my VB.NET-application.

Thanks a lot in advance,

Pieter

Jul 21 '05 #2

P: n/a
I doubt you being able to do so just through .NET framework. You might need
to use a system wide hook on the keyboard events and use
GetForegroundWindow() and follow it up to find the Process who owns that
handle (GetWindowThreadProcessId()) and find the process that way.
Of course, I am talking only about PInvoked methods. I dont know if there
are any direct mappings to .NET classes. You might be able to find PInvoke
signatures at www.pinvoke.net.

--
Girish Bharadwaj
http://msmvps.com/gbvb
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

In my VB.NET-application I need to get the Process that is currently active on the screen of the user. I need it to get back to that application after
that I brought mine to the front...

for exemple: user types in Word...
my application triggers an event, has to come to the foreground (when it is minimzed)
immediately after that the Word-process has to be set again to the front so the user can continu typing in word (and not in my application).

I don't think Process.GetCurrentProcess is the good answer, because that
points always to my VB.NET-application.

Thanks a lot in advance,

Pieter

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.