Sign in to follow this  

[C#] Running in the background

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

This topic is 3559 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this