So i wan't to make a shortcut for a button on my form, and it is controlling a timer, i wan't the timer to stop when i press Ctrl + L and it work's but only when the form is in focus, i wan't the shortcut to work when it's out of focus ect. when im on the desktop.
Heres my simple code that works when it's in focus :/
Oh, and if this topic is in the wrong section of the forum, feel free to move it, i couldn't really see other places to have this.
private void Form2_KeyDown_1(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.L)
{
timer1.Stop();
}
Loading
VulpesPosted Sep 7, 2011, 9:52 AM
Mikkel LarsenPosted Sep 7, 2011, 7:16 AM
Mikkel LarsenPosted Sep 7, 2011, 7:12 AM
Mikkel LarsenPosted Sep 7, 2011, 7:11 AM
VulpesPosted Sep 6, 2011, 5:12 AM
The only type of hook which can be installed from .NET without unmanaged C++ assistance is the low-level hook. Check out this article for how to install one using C#:
http://www.codeproject.com/KB/cs/globalhook.aspx
Prabhu RajaPosted Sep 6, 2011, 4:29 AM
i suggest you to Accesskey Button Property. In property window, you will find AccessKey Property. Set this to some Values (For example : S) . then you can invoke the button from any where by using Alt+S.
-------------------------------------------------
If this helps you, mark it as "Correct Answer"
NarayanPosted Sep 6, 2011, 3:56 AM
If an application is in focus, your event will work.
Is there only one form in your application, or you have other forms running. If not a single part of your application is in focus then it will listen to the event or you can invoke the same.