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

NarayanRank #8,477 · 221 reputationPosted Sep 5, 2011, 11:56 PM EDT
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.
Prabhu RajaRank #861 · 2.6K reputationPosted Sep 6, 2011, 12:29 AM EDT
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"
VulpesRank #55 · 29.2K reputationPosted Sep 6, 2011, 1:12 AM EDT
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
Mikkel Larsen7 reputationPosted Sep 7, 2011, 3:11 AM EDT
Mikkel Larsen7 reputationPosted Sep 7, 2011, 3:12 AM EDT
Mikkel Larsen7 reputationPosted Sep 7, 2011, 3:16 AM EDT
VulpesRank #55 · 29.2K reputationPosted Sep 7, 2011, 5:52 AM EDT