Click here to Skip to main content
15,906,624 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
if (e.Alt || e.KeyCode == Keys.F2)
           {

               MessageBox.Show("working");
           }


this code work only in active window of program
Posted

Well, yes.
Keystrokes go to the active input control, what did you expect?
 
Share this answer
 
Comments
#realJSOP 15-Dec-11 12:24pm    
A rrrrrrrrrrrrrrrrubber biscuit?
[no name] 15-Dec-11 12:33pm    
what i want-I start the program minimized to tray. And every 5 minutes there is pressing F2
OriginalGriff 15-Dec-11 14:01pm    
So you want your app to simulate the keyboard pressing F2 into the active application? Look at the SendKeys class:
http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx
You have to use global hook if you want to When user Pressed F1 your win form appear. hope this helps: [^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900