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

RE: How to get the Process the Active Proces? by mklapp

mklapp
Thu Sep 30 12:31:05 CDT 2004

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
>
>
>

Re: How to get the Process the Active Proces? by Girish

Girish
Thu Sep 30 12:46:11 CDT 2004

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" <pietercoucke@hotmail.com> wrote in message
news:%230fRwkvpEHA.2684@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
>
>