-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WT programs do not respond to arrow keys sent from the SendKeys API #7843
Comments
I don't know enough to be able to say. Sounds like a good hypothesis though. Is there an easy way to find out? |
It most certainly is the underlying reason. Currently all "improper" Optimally AutoHotkey, PowerTools, etc. should fix their |
Oh and just for reference... This is a minimal example of how you use #define NOMINMAX
#include <Windows.h>
#include <cstdio>
int main()
{
printf("Waiting 5 seconds for you to switch to Windows Terminal...\n");
Sleep(5000);
printf("Sending arrow up key\n");
INPUT ip{};
ip.type = INPUT_KEYBOARD;
ip.ki.wVk = VK_UP;
ip.ki.wScan = LOWORD(MapVirtualKeyW(VK_UP, MAPVK_VK_TO_VSC));
ip.ki.dwFlags = 0;
SendInput(1, &ip, sizeof(INPUT));
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));
return 0;
} (This example is only correct in the scope of the problem in this issue though.) |
While not explicitly permitted, a wide range of software (including Windows' own touch keyboard) sets the `wScan` member of the `KEYBDINPUT` structure to 0, resulting in `scanCode` being 0 as well. In these situations we'll now use the `vkey` to get a `scanCode`. Validation ---------- * AutoHotkey * Use a keyboard layout with `AltGr` key * Execute the following script: ```ahk #NoEnv #Warn SendMode Input SetWorkingDir %A_ScriptDir% <^>!8::SendInput {Raw}» ``` * Press `AltGr+8` while the Terminal is in the foreground * Ensure » is being echoed ✔️ * PowerToys * Add a `Ctrl+I -> ↑ (up arrow)` keyboard shortcut * Press `Ctrl+I` while the Terminal is in the foreground * Ensure the shell history is being navigated backwards ✔️ * Windows Touch Keyboard * Right-click or tap and hold the taskbar and select "Show touch keyboard" button * Open touch keyboard * Ensure keyboard works like a regular keyboard ✔️ * Ensure unicode characters are echoed on the Terminal as well (except for Emojis) ✔️ Closes #7438 Closes #7495 Closes #7843
While not explicitly permitted, a wide range of software (including Windows' own touch keyboard) sets the `wScan` member of the `KEYBDINPUT` structure to 0, resulting in `scanCode` being 0 as well. In these situations we'll now use the `vkey` to get a `scanCode`. Validation ---------- * AutoHotkey * Use a keyboard layout with `AltGr` key * Execute the following script: ```ahk #NoEnv #Warn SendMode Input SetWorkingDir %A_ScriptDir% <^>!8::SendInput {Raw}» ``` * Press `AltGr+8` while the Terminal is in the foreground * Ensure » is being echoed ✔️ * PowerToys * Add a `Ctrl+I -> ↑ (up arrow)` keyboard shortcut * Press `Ctrl+I` while the Terminal is in the foreground * Ensure the shell history is being navigated backwards ✔️ * Windows Touch Keyboard * Right-click or tap and hold the taskbar and select "Show touch keyboard" button * Open touch keyboard * Ensure keyboard works like a regular keyboard ✔️ * Ensure unicode characters are echoed on the Terminal as well (except for Emojis) ✔️ Closes #7438 Closes #7495 Closes #7843 (cherry picked from commit d51d8dc)
🎉This issue was addressed in #7900, which has now been successfully released as Handy links: |
🎉This issue was addressed in #7900, which has now been successfully released as Handy links: |
Environment
Steps to reproduce
Write a program in C# using the SendKeys API to emulate keypresses. Use this program to attempt to send arrow keys to a program running in Windows Terminal.
Expected behavior
The program in Windows Terminal should respond as if an arrow key has been pressed. In Powershell or CMD or most shells, the cursor should move according to the arrow key that is pressed.
Actual behavior
The cursor blinks as if a key has been pressed, but will not move. The program in WT does not respond in any other way. The up and down arrow keys sent by SendKeys WILL work in the dropdown menu however. It seems like programs running in WT will respond to most other keys appropriately.
The text was updated successfully, but these errors were encountered: