Advertisement
Guest User

Hotkey not working when showintaskbar set is false

a guest
Apr 14th, 2015
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. using HotKey;
  2. public partial class MainForm : Form
  3. {
  4. private Hotkeys.GlobalHotkey ghk;
  5. public MainForm()
  6. {
  7. InitializeComponent();
  8. ghk = new Hotkeys.GlobalHotkey(Constants.ALT + Constants.SHIFT, Keys.M, this);
  9. }
  10.  
  11. private void HandleHotkey()
  12. {
  13. WriteLine("Hotkey pressed!");
  14. }
  15. protected override void WndProc(ref Message m)
  16. {
  17. base.WndProc(ref m);
  18.  
  19. switch (m.Msg)
  20. {
  21. case Constants.WM_HOTKEY_MSG_ID:
  22. // Hotkey was pressed
  23. HandleHotkey();
  24. break;
  25. }
  26. }
  27.  
  28. private void MainForm_Load(object sender, EventArgs e)
  29. {
  30. WriteLine("Trying to register SHIFT+ALT+O");
  31. if (ghk.Register())
  32. {
  33. this.WindowState = FormWindowState.Minimized;
  34. this.ShowInTaskbar = false;
  35. WriteLine("Hotkey registered.");
  36. }
  37. else
  38. {
  39. WriteLine("Hotkey failed to register");
  40. }
  41. }
  42.  
  43. private void WriteLine(string text)
  44. {
  45. textBox1.Text += text + Environment.NewLine;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement