Autohotkey AltGr+7, AltGr+8, AltGr+9, and AltGr+0 reassignments lost in Windows Terminal Preview and Windows Terminal #9834

Closed
opened 2026-01-31 02:05:02 +00:00 by claunia · 5 comments
Owner

Originally created by @svivar on GitHub (Jul 24, 2020).

Environment

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.

Originally created by @svivar on GitHub (Jul 24, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none 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 <!-- A description of how to trigger this bug. --> # Expected behavior <!-- A description of what you're expecting, possibly containing screenshots or reference material. --> 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 <!-- What's actually happening? --> 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.
Author
Owner

@zadjii-msft commented on GitHub (Jul 28, 2020):

You know what, I bet I busted this up when I was doing #4999. Summoning @lhecker for debugging advice ☺️

@zadjii-msft commented on GitHub (Jul 28, 2020): You know what, I bet I busted this up when I was doing #4999. Summoning @lhecker for debugging advice ☺️
Author
Owner

@lhecker commented on GitHub (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:

#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}›

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.

@lhecker commented on GitHub (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: ```ahk #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}› ``` --- 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()`](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-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.
Author
Owner

@lhecker commented on GitHub (Aug 1, 2020):

I've opened a PR with an idea how I think this issue can be solved. 🙂 #7145

@lhecker commented on GitHub (Aug 1, 2020): I've opened a PR with an idea how I think this issue can be solved. 🙂 #7145
Author
Owner

@svivar commented on GitHub (Aug 1, 2020):

Thank you, @lhecker and @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:

<^>!,::Send <
<^>!.::Send >
<^>!7::Send {U+00AB}
<^>!8::Send {U+00BB}
<^>!9::Send {U+2039}
<^>!0::Send {U+203A}

Pressing those key sequences produces <>«»‹› in Notepad.

When I run the autohotkey script from @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}›

I am currently running AutoHotkey 1.1.33.02.

@svivar commented on GitHub (Aug 1, 2020): Thank you, @lhecker and @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: > <^>!,::Send < > <^>!.::Send > > <^>!7::Send {U+00AB} > <^>!8::Send {U+00BB} > <^>!9::Send {U+2039} > <^>!0::Send {U+203A} Pressing those key sequences produces <>«»‹› in Notepad. When I run the autohotkey script from @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}› I am currently running AutoHotkey 1.1.33.02.
Author
Owner

@ghost commented on GitHub (Aug 13, 2020):

:tada:This issue was addressed in #7145, which has now been successfully released as Windows Terminal Preview v1.2.2234.0.🎉

Handy links:

@ghost commented on GitHub (Aug 13, 2020): :tada:This issue was addressed in #7145, which has now been successfully released as `Windows Terminal Preview v1.2.2234.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.2.2234.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9834