Input sends initial hotkey to system

Report problems with documented functionality
Roang
Posts: 1
Joined: 04 Aug 2017, 06:59

Input sends initial hotkey to system

04 Aug 2017, 07:12

Am I trying to create a Umlaut Script that mimics the functionality Microsoft Word offers.
To this effect when you press CTRL + SHIFT + 7 (CTRL + &) and s the character ß should be inserted.
This is what I have come up with:


So far everything works as intended, except that after the run of the script the keyboard layout has changed.

When I exchange the Input command with InputBox there is no keyboard layout change.

Furthermore, the change in keyboard layout happens on the release of CTRL + Shift (the language switch combination for my Windows).

AHK Version: 1.1.26.01
Windows Version 10 Pro
lexikos
Posts: 5831
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Input sends initial hotkey to system

27 Nov 2017, 00:34

Input "catches" and blocks non-modifier keystrokes by default, so the system does not see them. As far as the system is concerned, you have merely pressed Ctrl+Shift and no other keys, so the language should be switched. This is by design.
lexikos
Posts: 5831
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Input sends initial hotkey to system

27 Dec 2017, 05:33

It occurred to me that you can probably prevent the language switch by sending a keystroke, just as AutoHotkey sends the mask key to prevent the window menu or Start menu from appearing. So I did some experimentation and learned a few things.

The Input command was also suppressing the key-up event of &/7, as it is designed to do. If you wait for the key to be released before calling Input, the system will see the key-release and so will not switch language (when ^& uses the "reg" hotkey method, at least).

Code: [Select all] [Download] GeSHi © Codebox Plus

^&::
KeyWait &
Input key, I C L1 T1
;...
However, this does not work if you release Ctrl or Shift before &/7, since in that case there is no event between Ctrl/Shift press and release. Instead, you can immediately "release" the key:

Code: [Select all] [Download] GeSHi © Codebox Plus

^&::
SendInput {Blind}{& up}
Input key, I C L1 T1
;...

Hook hotkeys will also cause this issue, because both key-press and key-release are suppressed. For example, just pressing this hotkey activates the language switch:
Sending any keyboard events (except Ctrl/Shift up) will suppress the language switch. I would suggest vk07 since it probably has no effect:

Code: [Select all] [Download] GeSHi © Codebox Plus

Send {Blind}{vk07 up}  ; Just the up event is sufficient.
This is not needed if you are sending some other keys (but you must send them before Ctrl or Shift is released).

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 6 guests