I am re-mapping the Qwerty layout (Danish) to Dvorak using AHK because I can't install custom keyboard layouts on this computer. So for instance these work fine:

:*:n::b  ; remap "n" to "b". This automagically also works for "N"-->"B".
:*:,::w  ; remap comma to lowercase "w".
:*:;::W  ; uppercase comma must be specifically coded.
:*:.::v  ; remap period to lowercase "v".

So far so good, but this doesn't work for the "colon" which should become an uppercase "V". According to the docs, I should be able to use the escape character but perhaps only in the output, not in the trigger? Because it's not a letter key, this solution does not work either.

I've tried several combinations:

:*::::V      ; "hotstring is missing its abbreviation"
:*C::::V     ; "hotstring is missing its abbreviation"
:*C: `: ::V  ; this just produces a colon...
:*:`:::V     ; "invalid hotkey"
:*C:`:::V    ; "invalid hotkey"
`:::V        ; "line does not contain a recognized action."

Note: of course I'm only trying one of the above at a time, but here they are all shown, not commented out.

  • Just curious, what kind of keyboard do you have? On my keyboard, shift+. is a > rather than a :. I was writing up an answer and realized it wouldn't be very helpful if I didn't adjust for the difference. Also, is there a particular advantage here for using Hotstrings instead of Hotkeys? – angerson May 5 '14 at 14:47
  • @ProtractorNinja: Oh, I didn't realize US layout has that there :-) It's a Danish layout (see image) but it doesn't really matter where the colon is, as long as it's a Shift position, so US has the same situation, just in a different physical place. I updated my post. – Torben Gundtofte-Bruun May 5 '14 at 14:53

The new AutoHotKey docs (which for some reason aren't linked from the old ones) retain the legacy docs' tendency to make finding out about things like this very difficult.

Your choice to use Hotstrings rather than Hotkeys has the benefit of never allowing the strings trigger each other (from Hotstrings):

By default, hotstrings are never triggered by keystrokes produced by any AutoHotkey script. This avoids the possibility of an infinite loop where hotstrings trigger each other over and over. In v1.1.06 and later, this behaviour can be controlled with #InputLevel and SendLevel. However, auto-replace hotstrings always use send level 0 and therefore never trigger hook hotkeys or hotstrings.

I think SendInput is supposed to operate similarly, by default, but I found that trying to use a simple hotkey with SendInput would risk triggering other hotkeys (and using nearly the same definition with a hotstring didn't work, probably due to colon-related quirks), so I had to manually ask the hotkey to use the Keyboard Hook (which is automatically installed because of the use of hotstrings):

#UseHook, On
:::SendInput, V ; Oddly enough, a colon as a hotkey trigger doesn't need 
                ; to be escaped, but a colon in a hotstring, unescaped or
                ; otherwise, just breaks things.
; Wouldn't get triggered by :, even if uncommented (that's good!)
; v::SendInput, colons in AHK are confusing
#UseHook, Off

You should be able to use hotstrings for remapping other keys as you have been already, although hotkeys might work instead if you really wanted them to, perhaps with #UseHook as I did in my example above and/or #InputLevel / SendLevel.

| improve this answer | |
  • Yes, this works -- actually just the basic :::send V was enough! Thank you for this! – Torben Gundtofte-Bruun May 6 '14 at 6:42
  • @TorbenGundtofte-Bruun Fantastic! Just watch out; hotkeys like this one are mischievous and like to trigger other operations if you're not careful. – angerson May 6 '14 at 15:03
  • Thanks for that warning; I'll keep it in mind if anything crops up. So far so good! – Torben Gundtofte-Bruun May 6 '14 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.