private void registerHotKey() { var helper = new WindowInteropHelper(this); if (!WindowsServices.RegisterHotKey(helper.Handle, HOTKEY_ID, WindowsServices.MOD_CTRL | WindowsServices.MOD_WIN | WindowsServices.MOD_ALT, (uint)WindowsServices.Keys.J)) { // handle error } }
protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); var helper = new WindowInteropHelper(this); var hwnd = helper.Handle; WindowsServices.SetWindowExTransparent(hwnd); source = HwndSource.FromHwnd(hwnd); source.AddHook(hwndHook); registerHotKey(); }
private void unregisterHotKey() { var helper = new WindowInteropHelper(this); WindowsServices.UnregisterHotKey(helper.Handle, HOTKEY_ID); }