After GUI Error Message keyboards events ignored? #20464

Closed
opened 2026-01-31 07:14:35 +00:00 by claunia · 6 comments
Owner

Originally created by @Zeroes1 on GitHub (Sep 11, 2023).

Windows Terminal version

1.18.1462.0

Windows build number

10.0.19045.3324

Other Software

No response

Steps to reproduce

portable
admin
default settings WT

trouble:

under CMD/GIT BASH/FAR Manager

Try run command:

like:
start 123

where 123 - not existed file in %path%

Windows show GUI error message: can't find 123. Check name and try again...
close message by Enter/Esc/AltF4 or mouse click on button OK
we return to WT and see what in console show message too: can't find file 123

AND now ... drumroll ...

Expected Behavior

keyboard events work, i press any key and see results

Actual Behavior

keybord not work, press any keys but nothing print... (keyboards events ignored?)
treatment method: click by mouse (any keys) inside WT window

the problem is 100% reproducible

Originally created by @Zeroes1 on GitHub (Sep 11, 2023). ### Windows Terminal version 1.18.1462.0 ### Windows build number 10.0.19045.3324 ### Other Software _No response_ ### Steps to reproduce portable admin default settings WT trouble: under CMD/GIT BASH/FAR Manager Try run command: like: start 123 where 123 - not existed file in %path% Windows show _GUI_ error message: can't find 123. Check name and try again... close message by Enter/Esc/AltF4 or mouse click on button OK we return to WT and see what in console show message too: can't find file 123 AND now ... drumroll ... ### Expected Behavior keyboard events work, i press any key and see results ### Actual Behavior keybord not work, press any keys but nothing print... (keyboards events ignored?) treatment method: click by mouse (any keys) inside WT window the problem is 100% reproducible
claunia added the Issue-BugIn-PRNeeds-Tag-FixProduct-ConptyArea-Windowing labels 2026-01-31 07:14:36 +00:00
Author
Owner

@Zeroes1 commented on GitHub (Sep 11, 2023):

under
Microsoft.WindowsTerminal_1.17.11461.0_x64.zip
same behavior

@Zeroes1 commented on GitHub (Sep 11, 2023): under Microsoft.WindowsTerminal_1.17.11461.0_x64.zip same behavior
Author
Owner

@codecruisedor commented on GitHub (Sep 12, 2023):

Yes, I can see the same issue in Terminal Version 1.17.11461.0. Seems like after the message is closed by clicking OK or clicking the close button, the focus is not returned to the WT rather we have to once click on it for the focus to return.

@codecruisedor commented on GitHub (Sep 12, 2023): Yes, I can see the same issue in Terminal Version 1.17.11461.0. Seems like after the message is closed by clicking OK or clicking the close button, the focus is not returned to the WT rather we have to once click on it for the focus to return.
Author
Owner

@Zeroes1 commented on GitHub (Sep 13, 2023):

Hmm, where is the focus? :) i alt-tab and alt-tab again (return to WT window) -not help...

@Zeroes1 commented on GitHub (Sep 13, 2023): Hmm, where is the focus? :) i alt-tab and alt-tab again (return to WT window) -not help...
Author
Owner

@zadjii-msft commented on GitHub (Sep 20, 2023):

I'm 99% sure I know what's going on here.

The MessageBox is parented to the console HWND. But for the Terminal, that HWND is not the Terminal's HWND - it's a hidden "pseudo hwnd". So when the MessageBox gets dismissed, and it returns foreground to its parent - the window that gets foreground is NOT the Terminal's window.

This is also probably Hard to solve. I'm not sure we get notified when we get foreground. And #13388 has some details on why yeeting foreground to the Terminal is hard.

@zadjii-msft commented on GitHub (Sep 20, 2023): I'm 99% sure I know what's going on here. The `MessageBox` is parented to the console HWND. But for the Terminal, that HWND is not the Terminal's HWND - it's a hidden "pseudo hwnd". So when the MessageBox gets dismissed, and it returns foreground to its parent - the window that gets foreground is NOT the Terminal's window. This is also probably **H**ard to solve. I'm not sure we get notified when we get foreground. And #13388 has some details on why yeeting foreground to the Terminal is hard.
Author
Owner

@Zeroes1 commented on GitHub (Jul 9, 2024):

may be interest for someones how to workaround this trouble...
for example if use AutoHotkey v2.x [https://www.autohotkey.com/]

add script (aka Little Magic Spell) at end file AutoHotkey64.ahk:

;------------------------- Restore Focus Windows Terminal if Lost -----------------------------
Loop {
  Try {
       hwnd := WinWait("A")
       className := WinGetClass(hwnd)

    if className == "PseudoConsoleWindow"
    {
     if WinExist("ahk_class CASCADIA_HOSTING_WINDOW_CLASS")
     WinActivate
    }

WinWaitNotActive hwnd
  }
}

@Zeroes1 commented on GitHub (Jul 9, 2024): may be interest for someones how to workaround this trouble... for example if use AutoHotkey v2.x [https://www.autohotkey.com/] add script (aka Little Magic Spell) **at end file AutoHotkey64.ahk**: ``` ;------------------------- Restore Focus Windows Terminal if Lost ----------------------------- Loop { Try { hwnd := WinWait("A") className := WinGetClass(hwnd) if className == "PseudoConsoleWindow" { if WinExist("ahk_class CASCADIA_HOSTING_WINDOW_CLASS") WinActivate } WinWaitNotActive hwnd } } ```
Author
Owner

@Zeroes1 commented on GitHub (Aug 30, 2024):

@zadjii-msft thanks it's work!

@Zeroes1 commented on GitHub (Aug 30, 2024): @zadjii-msft thanks it's work!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20464