Given a hotkey, how can I find which program owns it?
Caution: If you use Win 8 or later, do not use this utility as it will create some trouble - see comments.
If you are running a Windows earlier than Windows 8, then
Windows Hotkey Explorer is probably what you want. This is also mentioned in the StackOverflow question: Find out what process registered a global hotkey? (Windows API).
This works for me in Win10 (and probably all other even vaguely-recent versions of Windows)... also copied here from https://stackoverflow.com/a/43645062/995048 since this page seems to come up first in search results:
One possible way is to use the Visual Studio tool Spy++.
Give this a try:
- Run the tool (for me, it's at
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\spyxx_amd64.exe, or use
spyxx.exeto monitor 32-bit processes)
- In the menu bar, select Spy -> Log messages... (or hit Ctrl + M)
- Check All Windows in System in the Additional Windows frame
- Switch to the Messages tab
- Click the Clear All button
WM_HOTKEYin the listbox, or check Keyboard in Message Groups (if you're OK with more potential noise)
- Click the OK button
- Press the hotkey in question (Win + R, for example)
- Select the
WM_HOTKEYline in the Messages (All Windows) window, right click, and select Properties... in the context menu
- In the Message Properties dialog, click the Window Handle link (this will be the handle for the window that received the message)
- Click the Synchronize button on the Window Properties dialog. This will show the window in the main Spy++ window treeview.
- On the Window Properties dialog, select the Process tab
- Click the Process ID link. This will show you the process (In my Win + R case:
I've recently wrote a small utility - Hotkey Detective - for newer Windows versions (tested on 8.1 and 10). It simply shows what process owns the hotkey when you trigger the keystroke.
As distinct from other known tools, like Hotkey Explorer, my utility doesn't list all hotkeys, because that would involve artificial triggering all of them, and breaking the system in the end. In order to see what process is the guilty one, simply run my utility with administrator privileges and press the stolen hotkey. That's all.
This is an early beta, so report any issues if you find them.
This has probably been answered on Stack Overflow in this thread:
Here's Pauk's answer:
Your question piqued my interest, so I've done a bit of digging and while, unfortunately I don't have a proper answer for you, I thought I'd share what I have.
I found this example of creating keyboard hook (in Delphi) written in 1998, but is compilable in Delphi 2007 with a couple of tweaks.
It's a DLL with a call to
SetWindowsHookExthat passes through a callback function, which can then intercept key strokes: In this case, it's tinkering with them for fun, changing left cursor to right, etc. A simple app then calls the DLL and reports back its results based on a TTimer event. If you're interested I can post the Delphi 2007 based code.
It's well documented and commented and you potentially could use it as a basis of working out where a key press is going. If you could get the handle of the application that sent the key strokes, you could track it back that way. With that handle you'd be able to get the information you need quite easily.
Other apps have tried determining hotkeys by going through their Shortcuts since they can contain a Shortcut key, which is just another term for hotkey. However most applications don't tend to set this property so it might not return much. If you are interested in that route, Delphi has access to
IShellLinkCOM interface which you could use to load a shortcut up from and get its hotkey:
uses ShlObj, ComObj, ShellAPI, ActiveX, CommCtrl; procedure GetShellLinkHotKey; var LinkFile : WideString; SL: IShellLink; PF: IPersistFile; HotKey : Word; HotKeyMod: Byte; HotKeyText : string; begin LinkFile := 'C:\Temp\Temp.lnk'; OleCheck(CoCreateInstance(CLSID_ShellLink, nil, CLSCTX_INPROC_SERVER, IShellLink, SL)); // The IShellLink implementer must also support the IPersistFile // interface. Get an interface pointer to it. PF := SL as IPersistFile; // Load file into IPersistFile object OleCheck(PF.Load(PWideChar(LinkFile), STGM_READ)); // Resolve the link by calling the Resolve interface function. OleCheck(SL.Resolve(0, SLR_ANY_MATCH or SLR_NO_UI)); // Get hotkey info OleCheck(SL.GetHotKey(HotKey)); // Extract the HotKey and Modifier properties. HotKeyText := ''; HotKeyMod := Hi(HotKey); if (HotKeyMod and HOTKEYF_ALT) = HOTKEYF_ALT then HotKeyText := 'ALT+'; if (HotKeyMod and HOTKEYF_CONTROL) = HOTKEYF_CONTROL then HotKeyText := HotKeyText + 'CTRL+'; if (HotKeyMod and HOTKEYF_SHIFT) = HOTKEYF_SHIFT then HotKeyText := HotKeyText + 'SHIFT+'; if (HotKeyMod and HOTKEYF_EXT) = HOTKEYF_EXT then HotKeyText := HotKeyText + 'Extended+'; HotKeyText := HotKeyText + Char(Lo(HotKey)); if (HotKeyText = '') or (HotKeyText = #0) then HotKeyText := 'None'; ShowMessage('Shortcut Key - ' + HotKeyText); end;
If you've got access to Safari Books Online, there is a good section about working with shortcuts / shell links in the Borland Delphi 6 Developer's Guide by Steve Teixeira and Xavier Pacheco. My example above is a butchered version from there and this site.
Hope that helps!
I must recommend OpenArk. Under "Kernel" tab, "System Hotkey" page, you can find all registered hotkeys and corresponding processes. Remember to click "Enter KernelMode" button first.
These answers didn't work for me because--if I understand correctly--the hotkey had just been dropped on a
.lnk that did not get removed on an uninstall. Spy++ crashed when it was invoked.
Following the steps on this answer solved it: find the shortcut in question (mine was hiding in the start menu, without showing up under windows start button for whatever reason) and remove its hotkey setting (using backspace) or just delete the shortcut altogether.
I use Ctrl-Shift-C and Ctrl-Shift-V to copy and paste formatting in Word in win10. AMD's Radeon Pro Software robbed the Ctrl-Shift-C keyboard shortcut to enable/disable the camera. I disabled all hotkeys in the Radeon software and got the functionality back for Word, but one could reassign only the camera portion, or any other conflicting hotkey if one wanted to retain the Radeon hotkey function.