Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. if (e.KeyCode == Keys.F7)
  2. {
  3. A1 = !A1;
  4. }
  5.  
  6. // DLL libraries used to manage hotkeys
  7. [DllImport("user32.dll")]
  8. public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc);
  9. [DllImport("user32.dll")]
  10. public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
  11.  
  12. const int MYACTION_HOTKEY_ID = 1;
  13.  
  14. // Modifier keys codes: Alt = 1, Ctrl = 2, Shift = 4, Win = 8
  15. // Compute the addition of each combination of the keys you want to be pressed
  16. // ALT+CTRL = 1 + 2 = 3 , CTRL+SHIFT = 2 + 4 = 6...
  17. RegisterHotKey(this.Handle, MYACTION_HOTKEY_ID, 6, (int) Keys.F12);
  18.  
  19. protected override void WndProc(ref Message m) {
  20. if (m.Msg == 0x0312 && m.WParam.ToInt32() == MYACTION_HOTKEY_ID) {
  21. // My hotkey has been typed
  22.  
  23. // Do what you want here
  24. // ...
  25. }
  26. base.WndProc(ref m);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement