9

I'm a longtime Windows user who really likes to customize his Windows with lots of different utilities (some written by myself in Python) and AutoHotKey scripts. These all use global hotkeys for their functionality.

I was recently forced to upgrade to Windows 10. One of the problems has been that some hotkeys seem to be impossible to bind to. A couple of examples are CTRL-J and CTRL-V.

I was told that I needed to mark these apps to run as administrator via Properties, but even then they don't bind successfully to these hotkeys.

Any idea how I could bind to these hotkeys?

Update:

Looks like AHK is able to bind to these keys, but the ever-useful Ditto isn't, and my wxPython programs aren't either. Any idea why the last 2 aren't able to bind to these keys, and how I can fix that?

Yennefer
  • 5,704
  • 7
  • 31
  • 44
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
  • 1
    Both `^j::MsgBox` and `^v::MsgBox` work fine for me. This is a default installation with nothing special done; that is, without having modified the properties. Some Windows hotkeys are set in the registry (such as # + L), but I don't believe the two you mentioned are. – EJE Oct 21 '19 at 11:33
  • @EJE You're right, I updated my question. – Ram Rachum Oct 22 '19 at 12:51
  • 1
    You said "I was told that I needed to mark these apps to run as administrator via Properties" while it is probably the other way around: you need the *AutoHotkey* script to run as Administrator. See https://www.autohotkey.com/docs/Variables.htm#IsAdmin and code you can add to the start of your AutoHotkey script here https://www.autohotkey.com/docs/commands/Run.htm#RunAs – lintalist Oct 26 '19 at 09:05
  • @lintalist I don't understand, if AHK seems to be the only thing that actually manages to bind to these forbidden keys, unlike Ditto and wxPython, then why is it the only one that you suggest tweaking? – Ram Rachum Oct 29 '19 at 10:09
  • Do you see any bindings at shorcut explorer? http://www.rjlsoftware.com/software/utility/shortcutkeys/download.shtml – tukan Oct 30 '19 at 12:56
  • @tukan I tried shortcut explorer now, it said "There were no shortcut keys found in any of your Windows shortcuts." and then showed an empty list. – Ram Rachum Nov 01 '19 at 08:24
  • @RamRachum even when AHK binded those keys? That is weird. That probably means that the Win10 update broke the "traditional" way to map those. From which win10 version did you update to? My guess is that AHK is using some kind of low level way, the other are using "std." Ms way. – tukan Nov 01 '19 at 09:15
  • @tukan I upgraded from Windows 7 Ultimate to Windows 10. – Ram Rachum Nov 01 '19 at 12:16
  • ah, that explains a lot. Could you try it on fresh Windows 10 install if it behaves the same way? – tukan Nov 01 '19 at 12:35
  • I don't have a fresh Windows 10 install... That's a work computer. – Ram Rachum Nov 01 '19 at 15:18
  • I see well, you can try it at virtual machine. I have bad experience with the upgreades, something goes wrong every time. – tukan Nov 01 '19 at 21:18

1 Answers1

1

AutoHotkey implements keyboard hotkeys basically one of two ways:

  1. The system function RegisterHotkey. This only supports basic combinations of standard modifier keys and one key identified by VK. It does not support conditional hotkeys (#If). If the hotkey has already been registered by the system or another application, it fails.
  2. If RegisterHotkey couldn't be used for some reason or it failed to register the hotkey, a keyboard hook is used. This is the means by which it overrides system hotkeys and global hotkeys of other applications.

Normally, ^j and ^v are not registered as global hotkeys. Most Ctrl+ combinations are used within applications, so are not good choices for global hotkeys. ^v in particular would be a bad choice because it's often the "paste" hotkey (but not global).

When I use ^j:: or ^v:: in an AutoHotkey script on Windows 10.0.19041, ListHotkeys shows that they use the reg (RegisterHotkey) method. In that case, other programs should have no problem registering the hotkeys with RegisterHotkey as long as they are the first to do it. AutoHotkey does not do anything special to make RegisterHotkey work; it just calls the function, and awaits the WM_HOTKEY message.

However, if ListHotkeys was to show that ^j and ^v were using the k-hook method (in the absence of #UseHook or #If), that would mean something else has already registered those hotkeys. In that case, the only way to make RegisterHotkey work is to find whatever registered them (using general troubleshooting techniques like performing a clean boot), and get rid of it (or change its hotkeys if you can). For example, if you terminate explorer.exe, it is possible to register standard hotkeys like #e with RegisterHotkey.

Alternatively, if your program implements a low level keyboard hook (the same as AutoHotkey's), it can detect the hotkey by watching for Ctrl and J or V keydown and keyup events.

The program implementing the hotkey does not need to run as administrator. However, if the active/focused window belongs to a program which is running as administrator, only other programs which run as administrator or with UI access can intercept its keyboard input.

Lexikos
  • 987
  • 6
  • 16