You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Autohotkey AltGr+7, AltGr+8, AltGr+9, and AltGr+0 reassignments lost in Windows Terminal Preview and Windows Terminal #7064
Windows build number: [run `[Environment]::OSVersion` for powershell, or `ver` for cmd]
Windows Terminal version (if applicable):
Any other software?
Microsoft Windows [Version 10.0.19042.388]
Steps to reproduce
Expected behavior
I use the Spanish (ES) keyboard configuration and I have an autohotkey script that reassigns AltGr+, (comma), AltGr+. (period), AltGr+7, AltGr+8, AltGr+9, and AltGr+0 to <, >, «, », ‹, and ›, respectively.
I installed Windows Terminal and these keys-to-output reassignments worked great in tabs running PowerShell, cmd, Debian, and Ubuntu.
Actual behavior
I subsequently installed Windows Terminal Preview and found that AltGr+7, AltGr+8, AltGr+9, and AltGr+0 no longer produced any output. But the reassignment of outputs of AltGr+, (comma) and AltGr+. (period) to < and >, respectively, remain functional.
Windows Terminal also began exhibiting the same behavior.
The 6 autohotkey keys-to-output reassignments continue to work for all other applications.
This can be tested by adding a keyboard layout that has an AltGr key (Spanish, German, French, ...) and running the following AutoHotKey script:
#NoEnv; Recommended for performance and compatibility with future AutoHotkey releases.#Warn; Enable warnings to assist with detecting common errors.SendModeInput ; Recommended for new scripts due to its superior speed and reliability.SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.<^>!,::SendInput {Raw}<
<^>!.::SendInput {Raw}>
<^>!7::SendInput {Raw}«
<^>!8::SendInput {Raw}»
<^>!9::SendInput {Raw}‹
<^>!0::SendInput {Raw}›
AFAICS the underlying issue is that #4999 breaks international character inputs, by handling all key events, thereby suppressing follow up character events. Key events are based on ASCII, making them fundamentally unsuitable to accurately recreate character inputs purely based on key event data. Our prior logic ignored all key events for which ToUnicodeEx returned a valid character and those who aren't in the special key-combination list in terminalInput.cpp.
AutoHotKey uses SendInput(). Using a German keyboard layout SendInput() first generates a Fn-key sequence (vkey = 255, scan_code = 0, ch = 0). WT (since #4999) acknowledges this sequence and thus prevents the unicode character (e.g. "»") from ever being sent to the character event handler.
For the time being I suggest non-US Terminal users to set "experimental.input.forceVT": true in their config.
Thank you, Leonard Hecker (@lhecker) and Mike Griese (@zadjii-msft) . This comment may seem to be a digression to autohotkey, but I am posting it in case it's relevant to testing the fix to microsoft terminal preview. This is my autohotkey script:
Pressing those key sequences produces <>«»‹› in Notepad.
When I run the autohotkey script from Leonard Hecker (@lhecker), these are what appear in Notepad: <>«»‹›
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
<^>!,::SendInput {Raw}<
<^>!.::SendInput {Raw}>
<^>!7::SendInput {Raw}«
<^>!8::SendInput {Raw}»
<^>!9::SendInput {Raw}‹
<^>!0::SendInput {Raw}›
Activity
zadjii-msft commentedon Jul 28, 2020
You know what, I bet I busted this up when I was doing #4999. Summoning Leonard Hecker (@lhecker) for debugging advice☺️
lhecker commentedon Aug 1, 2020
This can be tested by adding a keyboard layout that has an AltGr key (Spanish, German, French, ...) and running the following AutoHotKey script:
AFAICS the underlying issue is that #4999 breaks international character inputs, by handling all key events, thereby suppressing follow up character events. Key events are based on ASCII, making them fundamentally unsuitable to accurately recreate character inputs purely based on key event data. Our prior logic ignored all key events for which
ToUnicodeExreturned a valid character and those who aren't in the special key-combination list interminalInput.cpp.AutoHotKey uses
SendInput(). Using a German keyboard layoutSendInput()first generates aFn-key sequence (vkey = 255, scan_code = 0, ch = 0). WT (since #4999) acknowledges this sequence and thus prevents the unicode character (e.g. "»") from ever being sent to the character event handler.For the time being I suggest non-US Terminal users to set
"experimental.input.forceVT": truein their config.lhecker commentedon Aug 1, 2020
I've opened a PR with an idea how I think this issue can be solved. 🙂 #7145
svivar commentedon Aug 1, 2020
Thank you, Leonard Hecker (@lhecker) and Mike Griese (@zadjii-msft) . This comment may seem to be a digression to autohotkey, but I am posting it in case it's relevant to testing the fix to microsoft terminal preview. This is my autohotkey script:
Pressing those key sequences produces <>«»‹› in Notepad.
When I run the autohotkey script from Leonard Hecker (@lhecker), these are what appear in Notepad: <>«»‹›
I am currently running AutoHotkey 1.1.33.02.
Fix #7064: Ignore key events without scan code (#7145)
Fix #7064: Ignore key events without scan code (#7145)
ConHost: Ignore WM_[SYS]KEYDOWN/WM_[SYS]KEYUP events with an invalid …