Home All Groups Group Topic Archive Search About

How to monitor which app window is the foreground window?

Author
21 Mar 2007 9:57 PM
Andrew
Hello, friends,

I need to write an assembly (C#.net 2.0 class library) to monitor all
applications
currently running in a PC. Especially, I need to know which window is the top
one, i.e., catch the event when a window becomes foreground window.  Should
I use WndProc() to catch related window messages? (I don't want
to use timer).

Any reference paper or sample source code? Thanks a lot.

Author
22 Mar 2007 4:59 AM
Manish Bafna
Hi,
This can be done through reflection.Find below the link which descrbies how
to monitor application.
http://www.codeproject.com/useritems/formscapture.asp
--
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.



Show quote
"Andrew" wrote:

> Hello, friends,
>
> I need to write an assembly (C#.net 2.0 class library) to monitor all
> applications
> currently running in a PC. Especially, I need to know which window is the top
> one, i.e., catch the event when a window becomes foreground window.  Should
> I use WndProc() to catch related window messages? (I don't want
> to use timer).
>
> Any reference paper or sample source code? Thanks a lot.
>
Author
22 Mar 2007 5:54 AM
Manish Bafna
Hi,
It can be done through WIN32 function GetForeGroundWindow() also.Find below
a link which elaborates more on this :
http://www.pinvoke.net/default.aspx/user32/GetForegroundWindow.html
please do let me know whether relection or getforegroundwindow has helped you
--
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.



Show quote
"Andrew" wrote:

> Hello, friends,
>
> I need to write an assembly (C#.net 2.0 class library) to monitor all
> applications
> currently running in a PC. Especially, I need to know which window is the top
> one, i.e., catch the event when a window becomes foreground window.  Should
> I use WndProc() to catch related window messages? (I don't want
> to use timer).
>
> Any reference paper or sample source code? Thanks a lot.
>
Author
22 Mar 2007 2:38 PM
Andrew
I believe it works when we call GetForeGroundWindow()  function. It will
return back the foreground window.

But, I don't want a person or timer get involved on when to call to this
function. This funcitons should be called when certain events are raised,
e.g., WM_ACTIVATE, WM_ACTIVATEAPP, etc., I guess...

Show quote
"Manish Bafna" wrote:

> Hi,
> It can be done through WIN32 function GetForeGroundWindow() also.Find below
> a link which elaborates more on this :
> http://www.pinvoke.net/default.aspx/user32/GetForegroundWindow.html
> please do let me know whether relection or getforegroundwindow has helped you
> --
> If my answer helped you,then please do press Yes below.
> Thanks and Regards.
> Manish Bafna.
> MCP and MCTS.
>
>
>
> "Andrew" wrote:
>
> > Hello, friends,
> >
> > I need to write an assembly (C#.net 2.0 class library) to monitor all
> > applications
> > currently running in a PC. Especially, I need to know which window is the top
> > one, i.e., catch the event when a window becomes foreground window.  Should
> > I use WndProc() to catch related window messages? (I don't want
> > to use timer).
> >
> > Any reference paper or sample source code? Thanks a lot.
> >

AddThis Social Bookmark Button