From 534b047525a2ac3cfea4cd2be5e551298b95f436 Mon Sep 17 00:00:00 2001 From: giotic <48352600+giotic@users.noreply.github.com> Date: Sun, 22 Nov 2026 08:38:59 +0100 Subject: [PATCH] Send navigation, Windows and Menu keys with the extended flag on Windows (#17174) --- libs/enigo/src/win/win_impl.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/enigo/src/win/win_impl.rs b/libs/enigo/src/win/win_impl.rs index 5506b4c95..9aaadc008 100644 --- a/libs/enigo/src/win/win_impl.rs +++ b/libs/enigo/src/win/win_impl.rs @@ -61,6 +61,12 @@ fn keybd_event(mut flags: u32, vk: u16, scan: u16) -> DWORD { LAYOUT = GetKeyboardLayout(current_window_thread_id); } scan = MapVirtualKeyExW(vk as _, 0, LAYOUT) as _; + // Without the extended flag, VM consoles and DirectX games read the navigation + // keys as the numpad keys that share their scan codes, and VM consoles ignore the + // Windows and Menu keys. + if matches!(vk, EVK_PRIOR..=EVK_DOWN | EVK_INSERT | EVK_DELETE | EVK_LWIN..=EVK_APPS) { + flags |= KEYEVENTF_EXTENDEDKEY; + } } }