Error The hotkey "e" will not be active because it does not exists in the current keyboard layout

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
auser01
Posts: 10
Joined: 05 Jan 2022, 07:52

Error The hotkey "e" will not be active because it does not exists in the current keyboard layout

Post by auser01 » 05 Jan 2022, 08:01

From my old Windows 7 computer I have copy/pasted AutoHotkey commands and when I start AutoHotkey it reports errors:
Note: Error The hotkey "e" will not be active because it does not exists in the current keyboard layout.

On top is error message and behind is AutoHotkey script.
key.jpg
key.jpg (18.42 KiB) Viewed 1283 times
The problem is letter "e" does not exists on my keyboard. This is actually ANSII character that in Windows 1250 code page is character "č" that exits on my keyboard.

This got to be some code page problems. How to fix this code page problems?

Thanks


auser01
Posts: 10
Joined: 05 Jan 2022, 07:52

Re: Error The hotkey "e" will not be active because it does not exists in the current keyboard layout

Post by auser01 » 06 Jan 2022, 01:40

Hi,
I have got SC027 as scan code. But now my script does not work as intended.

What I would like to do? In "Vim" text editor I would like to completely ignore <Caps Lock> key. E.g. if <Caps Lock> is turned on and I press letter "a" normally I would get letter "A", but I want to get letter "a", so ignoring the <Caps Lock> key.

I have had the following code on my Windows 7 machine (sorry I don't remember the AutoHotKey version).

Code: Select all

#IfWinActive ahk_class Vim
a::
+a::
b::
+b::
c::
+c::
SC027::
;č::
;+č::
;ć::
;+ć::
d::
+d::
;đ::
;+đ::
e::
+e::
f::
+f::
g::
+g::
h::
+h::
i::
+i::
j::
+j::
k::
+k::
l::
+l::
m::
+m::
n::
+n::
o::
+o::
p::
+p::
q::
+q::
r::
+r::
s::
+s::
;š::
;+š::
t::
+t::
u::
+u::
v::
+v::
w::
+w::
x::
+x::
y::
+y::
z::
+z::
;ž::
;+ž::
varShift := GetKeyState("Shift")
varKeyAll := A_ThisHotkey
StringReplace, varKey, varKeyAll, +
StringUpper, varKeyUpper, varKey
StringLower, varKeyLower, varKey
 
if varShift = 1
  	{
   		Send %varKeyUpper%
   	}
   	else
   	{
   		Send %varKeyLower%
   	}

return
#IfWinActive
I have commented out the line 9 with text "č::" to get ";č::" and now added line 8 above with text "SC027::", but now when I press letter "č" in Vim text editor, I get text: sc027, but obviously I want to have "č" letter displayed in text editor.

Any idea how to fix a problem?
Thanks

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Error The hotkey "e" will not be active because it does not exists in the current keyboard layout

Post by mikeyww » 06 Jan 2022, 07:31

A demonstration is below.

Code: Select all

key = a
Send %key%       {%key%}`n
key = SC027
Send %key%   {%key%}`n

auser01
Posts: 10
Joined: 05 Jan 2022, 07:52

Re: Error The hotkey "e" will not be active because it does not exists in the current keyboard layout

Post by auser01 » 06 Jan 2022, 08:15

From my code in line 8 I have changed:
SC027::
to
SC027:: Send {SC027}

I reloaded the script and now letter "č" works fine in both cases, CapsLocks turned on and CapsLocks turned off.

But strange problem appeared, when I type:
abcčdefghijklmnoprstuvz
it is displayed in both cases CapsLock turned on or off:
ččččdefghijklmnoprstuvz

For some reason letters a, b, c, č and d all get changed to "č". I like the "č" getting into "č", but not a, b, c and d. It is interesting that all other keys are working properly.

Any idea what is the problem?
Regards

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Error The hotkey "e" will not be active because it does not exists in the current keyboard layout

Post by mikeyww » 06 Jan 2022, 09:18

You introduced an implicit Return.

Another example is below.

Code: Select all

#UseHook
a::
+a::
SC027::
Send % Format("{{:" (Instr(A_ThisHotkey, "+") ? "U" : "L") "}}", RegExReplace(A_ThisHotkey, "\W"))
Return
#UseHook Off
Introduction and Simple Examples:
If a hotkey needs to execute only a single line, that line can be listed to the right of the double-colon. In other words, the return is implicit.
Simpler:

Code: Select all

#UseHook
a::
+a::
SC027::
+SC027::
Send % RegExReplace(A_ThisHotkey, "\w") "{" RegExReplace(A_ThisHotkey, "\W") "}"
Return
#UseHook Off
Or:

Code: Select all

#SingleInstance Force
Loop {
 WinWaitActive, ahk_exe notepad.exe
 originalCapsLockState := GetKeyState("CapsLock", "T")
 SetCapsLockState, Off
 SoundBeep, 1500
 WinWaitNotActive
 SetCapsLockState, %originalCapsLockState%
 SoundBeep, 1000
}

auser01
Posts: 10
Joined: 05 Jan 2022, 07:52

Re: Error The hotkey "e" will not be active because it does not exists in the current keyboard layout

Post by auser01 » 11 Jan 2022, 01:48

Hi,
I have now used:

Code: Select all

SC027::
+SC027::
Send % RegExReplace(A_ThisHotkey, "\w") "{" RegExReplace(A_ThisHotkey, "\W") "}"
Return
and it works fine. If CapsLock is pressed or no, letter "č" is always at lower key state as expected.

Now I have 4 more keys to do the same. I did:

Code: Select all

SC028::
+SC028::
Send % RegExReplace(A_ThisHotkey, "\w") "{" RegExReplace(A_ThisHotkey, "\W") "}"
Return
Now I have tree more keys to do the magic, for keys:
"01B", "01A" and "02B", but for some reason this three keys do not work as above code. For example I did:

Code: Select all

01B::
+01B::
Send % Format("{{:" (Instr(A_ThisHotkey, "+") ? "U" : "L") "}}", RegExReplace(A_ThisHotkey, "\W"))
Return
and when I reload the script I get error:
Error at line 473.
Line Text: 01B::
Error: Invalid hotkey.

The script was not reloaded; the old version will remain in effect.
I also tested last block of code from your previous sample (starting from #SingleInstance...) in separate script, made sure all AutoHotKeys programs are closed down, run the script, tested in Notepad, and it looks like no effect, all letters of alphabet appear like they are typed down respecting CapsLock key pressed or not pressed.

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Error The hotkey "e" will not be active because it does not exists in the current keyboard layout

Post by mikeyww » 11 Jan 2022, 06:45

01B is not the name of a key, hence the error.

auser01
Posts: 10
Joined: 05 Jan 2022, 07:52

Re: Error The hotkey "e" will not be active because it does not exists in the current keyboard layout

Post by auser01 » 13 Jan 2022, 01:23

Hi,
in AutoHotKey keyboard detection I get:
- 01B for letter đ,
- 01A for letter š,
- 02B for letter ž
Please see attachment.
Regards
Attachments
letters.jpg
letters.jpg (222.57 KiB) Viewed 988 times

gregster
Posts: 9002
Joined: 30 Sep 2013, 06:48

Re: Error The hotkey "e" will not be active because it does not exists in the current keyboard layout

Post by gregster » 13 Jan 2022, 02:24

Then use SC01B instead of 01B (beause it's in the SC - scan code - column), like you did here.

auser01
Posts: 10
Joined: 05 Jan 2022, 07:52

Re: Error The hotkey "e" will not be active because it does not exists in the current keyboard layout

Post by auser01 » 17 Jan 2022, 08:57

Problem solved!!!
@gregster, thank you for your feedback. Sure I made a mistake and forgot to prepend "SC" in front of scan code.

Post Reply

Return to “Ask for Help (v1)”