Sign in to follow this  
awesty

[C#] Running in the background

Recommended Posts

awesty    124
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
Tubos    211
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

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