From d3dd06381361ae5060d503b9903ccd22feb798ef Mon Sep 17 00:00:00 2001 From: Francesco Bonacci Date: Wed, 20 May 2026 23:36:06 +0200 Subject: [PATCH] fix(cua-driver-rs/windows): more honest hotkey no-match error message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The error returned when the UIA accelerator scan finds nothing said: "could not find a descendant UIA AcceleratorKey matching ..." But the scan tries BOTH approaches: the `UIA_AcceleratorKeyPropertyId` property AND the `(Ctrl+X)`-style hint in element Names (added for modern Notepad, which doesn't set AcceleratorKey). The original wording implied only the first was tried, which is misleading when 30+ elements were scanned and nothing matched. Updated to: "could not find a UIA AcceleratorKey or `(Ctrl+X)`-style name hint matching ..." Also added a one-line hint about the most common cause (menu-nested actions like modern Notepad's Save behind the File menu) so the caller knows what to look for in `get_window_state` output. Found via end-to-end Claude Code test in #1611 review — Claude noted the wording was a touch misleading after seeing the actual error message it received from `cua-driver call hotkey ctrl+s` on modern Notepad. Co-Authored-By: Claude Opus 4.7 --- .../crates/platform-windows/src/tools/impl_.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libs/cua-driver-rs/crates/platform-windows/src/tools/impl_.rs b/libs/cua-driver-rs/crates/platform-windows/src/tools/impl_.rs index 8242ba4fea..4c3dcb5eff 100644 --- a/libs/cua-driver-rs/crates/platform-windows/src/tools/impl_.rs +++ b/libs/cua-driver-rs/crates/platform-windows/src/tools/impl_.rs @@ -1588,12 +1588,15 @@ impl Tool for HotkeyTool { )), Ok(Ok((false, scanned))) => ToolResult::error(format!( "hotkey on a modern XAML / UWP target (pid {raw_pid}, hwnd {hwnd}) \ - could not find a descendant UIA AcceleratorKey matching \ - `{key_display_for_result}` (scanned {scanned} element(s)). \ + could not find a UIA AcceleratorKey or `(Ctrl+X)`-style name hint \ + matching `{key_display_for_result}` (scanned {scanned} element(s)). \ PostMessage WM_KEYDOWN/UP is ignored by this target's input pipeline. \ - Call `get_window_state(pid={raw_pid}, window_id={hwnd})` to inspect \ - available UIA actions, then use an exposed accelerator or invoke/click \ - the matching element." + Common cause: the action is nested behind a closed menu (e.g. modern \ + Notepad's Save under the File menu) — its element isn't in the visible \ + subtree until the menu is opened. Call \ + `get_window_state(pid={raw_pid}, window_id={hwnd})` to inspect available \ + UIA actions, then use an exposed accelerator or `click` the matching \ + element directly." )), Ok(Err(e)) => ToolResult::error(format!("hotkey (UIA path): {e}")), Err(e) => ToolResult::error(format!("Task error: {e}")),