Global hotkeys in WPF working from every window

You can use the same approach as in WinForms with some adaptation: use WindowInteropHelper to get HWND (instead of Handle property of a form) use HwndSource to handle window messages (instead of overriding WndProc of a form) don’t use Key enumeration from WPF – it’s values are not the ones you want Complete code: [DllImport(“User32.dll”)] … Read more

Customizable Shortcuts in Java Application

Shortcuts may be specified as accelerators in instances of Action. Less flexibly, shortcuts may be represented by KeyEvent instances obtained via KeyListener. Either may be stored in java.util.Preferences or javax.jnlp.BasicService, as suggested here. I’m unaware of a general purpose library, but this game offers an RCKeys dialog to remap keys. It includes the essential functionality … Read more

Global Hotkey with X11/Xlib

Your program works here. My guess is you have another modifier active, such as NumLock. GrabKey only works on the exact modifier mask. For example here is some (GPL) code from metacity window manager /* Grab/ungrab, ignoring all annoying modifiers like NumLock etc. */ static void meta_change_keygrab (MetaDisplay *display, Window xwindow, gboolean grab, int keysym, … Read more

How can I register a global hot key to say CTRL+SHIFT+(LETTER) using WPF and .NET 3.5?

This is a full working solution, hope it helps… Usage: _hotKey = new HotKey(Key.F9, KeyModifier.Shift | KeyModifier.Win, OnHotKeyHandler); … private void OnHotKeyHandler(HotKey hotKey) { SystemHelper.SetScreenSaverRunning(); } Class: using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net.Mime; using System.Runtime.InteropServices; using System.Text; using System.Windows; using System.Windows.Input; using System.Windows.Interop; namespace UnManaged { public class HotKey : IDisposable … Read more

Set global hotkeys using C#

Please note that this code will not trigger events in console application projects. You have to use WinForms project for events to fire. This is the correct code: public sealed class KeyboardHook : IDisposable { // Registers a hot key with Windows. [DllImport(“user32.dll”)] private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk); … Read more