Page 1 of 1

The hotkey #q will not be active because it does not exist in the current keyboard layout.

Posted: 02 Jun 2016, 08:18
by voidbent
From time to time I randomly get the following note message while starting AutoHotkey: "Note: The hotkey #q will not be active because it does not exist in the current keyboard layout"

Appropriate hot key is defined like this:

Code: Select all

#q::
  SendInput {U+0301}
  return
I use AutoHotkey v1.1.24.00

Re: The hotkey #q will not be active because it does not exist in the current keyboard layout.

Posted: 02 Jun 2016, 21:46
by lexikos
I would guess that from time to time you randomly change your default keyboard layout to one where 'q' does not exist...

It is unlikely to be a bug. If it matters, I have been using #q as a hotkey for years and never had that problem, except (as expected) when using a keyboard layout which does not assign the letter 'q' to a key.

Re: The hotkey #q will not be active because it does not exist in the current keyboard layout.

Posted: 14 Nov 2017, 12:36
by voidbent
lexikos wrote:I would guess that from time to time you randomly change your default keyboard layout to one where 'q' does not exist...
No, I don't. I can run AutoHotkey 3 times in a row and it will show me the error 2 out of 3 times. I don't change default keyboard layout between runs.
lexikos wrote:It is unlikely to be a bug. If it matters, I have been using #q as a hotkey for years and never had that problem, except (as expected) when using a keyboard layout which does not assign the letter 'q' to a key.
I've been using #q as a hotkey for maybe a decade already, and the bug reproduces for several years. It reproduces on all PCs that I'm using.

Re: The hotkey #q will not be active because it does not exist in the current keyboard layout.

Posted: 14 Nov 2017, 13:49
by Guest
Perhaps the programs you're using do "something" to your keyboard layout, who knows. Perhaps another hotkey/hotstrings is sending a key-combo that switches your keyboard language and you don't notice. Or it is just a mystery ;)

Is it only #q or other keys as well? If it is just #q why don't you switch to using the scancode for the key so it always works regardless of layout? See https://autohotkey.com/docs/KeyList.htm#SpecialKeys

Re: The hotkey #q will not be active because it does not exist in the current keyboard layout.

Posted: 14 Nov 2017, 16:19
by voidbent
Guest wrote:Perhaps the programs you're using do "something" to your keyboard layout, who knows. Perhaps another hotkey/hotstrings is sending a key-combo that switches your keyboard language and you don't notice. Or it is just a mystery ;)
I don't have any other keyboard/language related applications installed.
Guest wrote:Is it only #q or other keys as well?
All other WinKey+Letter keys behave in the same way. An error message appears for each single WinKey+Letter hotkey I use in my script.

Re: The hotkey #q will not be active because it does not exist in the current keyboard layout.

Posted: 14 Nov 2017, 16:27
by jeeswg
- So, sometimes you get the problem, sometimes you don't. What regularity, roughly?
- Was there a time period when the script would always work correctly, and then at some point you got the occasional error?
- If you create a new script like the one below, and close all other scripts:

Code: Select all

#q::
MsgBox, % A_ThisHotkey
return
Does it work? If so, sometimes when I've had major problems, that I don't understand the cause of, I copy the script, and delete chunks of it until the problem goes away, and try and pinpoint where the problem is.
- Do you have any problems with other hotkeys?
- If you create hotkeys like #w or ^q, do they work?
- After the error, does the script actually run as expected, or are there problems.
- What language settings do you use, have you ever changed them?
- Do you have any other keyboard-related software?
Cheers.

[EDIT:]
- File encoding issues? I.e. what is the encoding of the script?
- Try and think of anything keyboard-related, or anything in the script, that could be a source of the problem.
- A workaround script:

Code: Select all

LWin & q::
RWin & q::
MsgBox, % A_ThisHotkey
return
- Is there any weird code near any of the #q hotkey labels? Or weird, possibly invisible, characters.
- Try commenting out all of the #q hotkeys, and adding a new one at the bottom of the script.
- I had this problem at some point last year it turns out, I don't know what caused it, but I must have fixed it. If you try the things that I suggested, hopefully you'll be able to figure something out.

Re: The hotkey #q will not be active because it does not exist in the current keyboard layout.

Posted: 14 Nov 2017, 18:10
by voidbent
jeeswg wrote:- What language settings do you use, have you ever changed them?
It appears that this is what causes the problem. Thanks for helping me to figure it out!

I have "English (United States)", "Russian (Ukraine)" and "Ukrainian (Enhanced)" languages installed. The script doesn't work if the current language is Russian or Ukrainian at the moment when I start AutoHotkey (both languages use Cyrillic instead of Latin alphabet).

If I start AutoHotkey when current language is "English (United States)" and then change it to Russian or Ukrainian, the script works as expected and #q hotkey works as well. So I assume it must be some problem in keyboard layout detection.

Re: The hotkey #q will not be active because it does not exist in the current keyboard layout.

Posted: 15 Nov 2017, 02:01
by lexikos
Hotkeys are registered at program startup, using the keyboard layout which is active at the time. This is by design.

Re: The hotkey #q will not be active because it does not exist in the current keyboard layout.

Posted: 15 Nov 2017, 10:11
by voidbent
lexikos wrote:Hotkeys are registered at program startup, using the keyboard layout which is active at the time. This is by design.
Is there any way to change this default behavior?

#q hotkey works in Russian and Ukrainian languages, so I'd prefer to change keyboard layout to English (United States) before hotkey initialization and then change it back in my script.

Re: The hotkey #q will not be active because it does not exist in the current keyboard layout.

Posted: 15 Nov 2017, 14:17
by Guest
use the scancode - see few posts up

Re: The hotkey #q will not be active because it does not exist in the current keyboard layout.  Topic is solved

Posted: 27 Dec 2017, 17:14
by lexikos
This should no longer happen for the a-z keys due to:
v1.1.27.00 wrote:Changed a-z to mean vk41-vk5A when absent from the keyboard layout, except with Raw mode or when sending single unmodified characters. This allows hotkeys and sent keyboard shortcuts to work more intuitively on certain non-English keyboard layouts.