public static void RegisterHotKey(string hotkeyStr) { if (string.IsNullOrEmpty(hotkeyStr)) { UnregisterHotKey(); return; } hotkey = new Hotkey(hotkeyStr); if (hotkeyHook != null) { hotkeyHook.Dispose(); } hotkeyHook = new HotkeyHook(); // register the event that is fired after the key press. hotkeyHook.KeyPressed += new EventHandler <KeyPressedEventArgs>(QuickPasteEx); hotkeyHook.RegisterHotKey(hotkey.ModifierKey, hotkey.Key); }
public MainWindow() { this.InitializeComponent(); this.hkHook = new HotkeyHook(); this.InitHotkeys(); this.dragHook = new DragWindowHook(); this.InitDragHook(); //InitTrayIcon(); this.CmdWindow = new CommandWindow(); this.kbHook = new KeyboardHook(false); kbHook.Subscribe(System.Windows.Forms.Keys.LMenu); kbHook.KeyChanged += (_, args) => { Console.WriteLine(args.Key + ", Pressed: " + args.KeyDown); }; this.Hide(); }