Jump to content
  • Advertisement
Sign in to follow this  
awesty

[C#] Running in the background

This topic is 3771 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

Is it possible to keep my application listening for key presses even when it isn't in focus? No, I'm not making a key logger. I just need this for some hotkeys in my app.

Share this post


Link to post
Share on other sites
Advertisement
Yes, it is possible and there are several ways to implement this.


You could use P/Invoke and then constantly call GetAsyncKeyState in a loop, with some delay in between.
	[DllImport("user32.dll")]
static extern short GetAsyncKeyState(int vKey);

Or you could use hooks.
There should be tons of examples on the net.


edit:
Sorry, forget it - these two options are not feasible when you just want to implement hotkeys.

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!