Sign in to follow this  

[C#] Running in the background

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.
static extern short GetAsyncKeyState(int vKey);

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

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

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