Capturing a key without focusing the window
I have a application that always checks if a key like F12 is pressed. It doesn't need to have in focus of my main window of my app. I tried this code: public int a = 1; // DLL libraries used to manage hotkeys [DllImport("user32.dll")] public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc); [DllImport("user32.dll")] public static extern bool UnregisterHotKey(IntPtr hWnd, int id); const int MYACTION_HOTKEY_ID = 1; public Form1() { InitializeComponent(); // Modifier keys codes: Alt = 1, Ctrl = 2, Shift = 4, Win = 8 // Compute the addition of each combination of