0

I am re-mapping the Qwerty layout to Dvorak using AHK because I can't install custom keyboard layouts on this computer. Most of my remapping just follows a simple pattern, and this works well:

:*: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.

Problem: The Danish layout has three special characters, and these won't trigger a remapping. The problem is (probably?) the same for all three keys, so let's just look at one of them, the "a-ring" in the top row.

enter image description here

I've tried several trigger variations but the problem seems to be that AHK in some cases ignores the trigger and just outputs the physical key. Notably, the entire remapping script seems to become suspended after this, but starts working again after I suspend&resume the script. There are no warnings or errors, and other scripts still work.
(Of course I'm only trying one of these at a time, but here they are all shown, not commented out.)

:*:å::<             ;-- erroneously still produces "å".
:*:Å::>             ;-- erroneously still produces "Å".
:*C:å::<            ;-- erroneously still produces "å".
:*C:Å::>            ;-- erroneously still produces "Å".

or it will balk at the trigger definition in the script:

å::send <           ;-- Ã¥ invalid hotkey.
Å::send >           ;-- Ã…  invalid hotkey.
{ASC 0229}::send <  ;-- ASC 0229} invalid hotkey.
{ASC 0197}::send >  ;-- ASC 0197} invalid hotkey.

How should the trigger be formulated, in order to capture these keys?

1

2 Answers 2

1

AHK has a KeyHistory function that can reveal the scan code of each physical key. Using that, I determined that the "a-ring" key has SC01A which can be referenced in AHK:

SC01A::<  ; the "a-ring" key should produce a "<" character. 

Uppercase is handled automatically, so that's really all there is to it!

Note that AHK scan codes can be very different from what you'd see if you did a Google Images search for keyboard scan code charts, so don't rely on that!

0

If you don't know the keyname for a key, you generally have two other options: virtual key code (VK) and scan code (SC). VK is how Windows represents the key at the software layer, and SC is the firmware identity for that POSITION on the keyboard. In this case, In this case, it may be easier to use SC's, since Microsoft's documentation doesn't enumerate VKs for the keys you showed. At any rate, for this kind of ergonomic remapping, it's probably better to use SCs so that it has a better chance of behaving consistently (as far as your hands can tell) if you get a different keyboard.

To find the VK and/or SC of a given key, you may be able to find the information online (such as the above-referenced Microsoft documentation link), but if that fails, you can alternatively (and in my opinion, preferably) do the following:

  1. make sure you have at least one script running that has the keyboard hook installed using the directive #InstallKeybdHook. If none of your current script use the keyboard hook, you can make a "mystery key detector" specifically for this purpose as follows:
#InstallKeybdHook ;installs the keyboard hook
KeyHistory ;for your convenience, brings up the script's Key History tab. This is optional
  1. Open the script's management window to the Key History tab. If you used the above script, it will open automatically for you when run.
  2. Press the key you are trying to identify.
  3. From the "view" drop-down menu, refresh the Key History. The key you are identifying should be near the bottom.
  4. repeat steps 3-4 as needed
2
  • Thanks - can you please elaborate what it means that the keyboard hook must be installed"? Is that a particular command I could add to the script? May 12, 2014 at 10:54
  • @TorbenGundtofte-Bruun you need to use a directive, #InstallKeybdHook. You only need the keyboard hook for your "mystery key detector" script; after you figure out the key code, you can close that script. Will revise answer for clarity Oct 31, 2022 at 23:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .