Jump to content
  • Advertisement
Sign in to follow this  
one mind

How to watch for system events in .net?

This topic is 4594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am trying to recognize when a user makes another program active by clicking it when my program is minimized. Eg, when my .net winform program starts, it is minimized and hidden and has an icon shown in the tray. I want my program to maximize and show itself when the user makes another program active. For example, they start my program and its running in the background, they then click on a notepad window then my program shows itself. Is there a way to do this without hooks because a really dont get how to use them with .net. Thanks :)

Share this post


Link to post
Share on other sites
Advertisement
You could P/Invoke a call to GetForegroundWindow every second or so (in a timer, for example) and if the window you're after becomes the active one then you can do whatever.

Though I would question the value of this. Why do you want your program to pop up when a certain window becomes active? Perhaps there's a better solution, but we can't help you if you don't give us some more background...

Share this post


Link to post
Share on other sites
Thanks Dean,

I am making a program that calculates poker statistics on the fly by watching what cards come out on online poker clients.

The way my program is supposed to work is, the user starts it and it will run in the background with a tray icon. When a user activates a poker table, my program displays and starts doing the stats.

The reason i need to know what window is active is because, some people have 2-4 poker tables open at once but only one can be active at a time. When they click a table, my program will know which cards to read so that way they can use one program for many tables instead of trying to cram in 4 instances of my program with 4 tables.

I'll look into your solution,

Cheers :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!