Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AHK/AHK_L Input EndKey bug on Colemak Keyboard layout Win 7



  • Please log in to reply
3 replies to this topic
Maniac
  • Members
  • 445 posts
  • Last active: Jan 06 2016 12:02 PM
  • Joined: 28 Aug 2009
When Colemak v1.1 is the default keyboard layout on Windows 7 (and possibly XP or Vista, but untested), using ` and ~ as endkeys for the Input function map to R and G respectively; so R and G terminate the input.

This *only* happens when they are mapped as EndKeys. The actual input character is detected correctly.

This does not happen when using Colemak v1.0 on XP (1.0 does not work on Windows 7 or Vista).

Thanks!

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
AutoHotkey uses VkKeyScanEx to map the end chars to virtual key codes or scan codes when it begins collecting input, for performance. (The keyboard hook can be considered performance-critical.) There are a few problems with this method:
[*:3qidst8w] It uses the script's keyboard layout to perform the mapping. Most scripts would be using the system default layout, which may be different to the active window's layout. Even if it used the active window's layout, the user could switch to some other window, or even change the keyboard layout in use by the active window. [*:3qidst8w] It isn't designed to handle Ctrl or Alt modifiers, only Shift. [*:3qidst8w] There may be multiple keys/key-combinations which can produce any given end char. Only the key or key-combination returned by VkKeyScanEx has any chance of working.When I tested, VkKeyScanEx returned Ctrl+Alt+R for ` and Ctrl+Alt+Shift+R for ~. I've confirmed that these key combinations do indeed produce ` and ~, so VkKeyScanEx is producing correct results (though not the results we want). Side note: AltGr and Ctrl+Alt are equivalent.

In this case, using {vkC0} in place of ``~ might provide a partial workaround.

There doesn't seem to be any simple way to fix this, but I've made a note to look into it again at a later date.

Maniac
  • Members
  • 445 posts
  • Last active: Jan 06 2016 12:02 PM
  • Joined: 28 Aug 2009
OK, thanks Lexikos! For the time being I have worked around the problem a different way, though I may try your suggestion with vkC0.

Maniac
  • Members
  • 445 posts
  • Last active: Jan 06 2016 12:02 PM
  • Joined: 28 Aug 2009
✓  Best Answer

I was investigating another issue with keyboard layouts and ran across this issue again. I realized I don't actually need these keys as EndKeys because my input length is 1. I've removed them from the Endkeys and then check the character that was typed vs my list of terminating characters. Not sure why I didn't think of this before....