menu_choose
This directory provides utilities for navigating and selecting items from dropdowns, context menus, or autocomplete lists using voice commands. It automates repetitive arrow-key navigation by translating a spoken number into the exact sequence of keypresses required to make a selection.
Core Architecture
The selection mechanism is split into two primary files:
- menu_choose.py: Defines Python-based actions using the Talon API to dynamically generate keystrokes based on the item index.
- menu_choose.talon: Exposes the Python actions to the Talon voice engine as standard spoken commands.
How It Works
The implementation relies on keyboard emulation to navigate active menus that are already open and focused.
- Downward Selection: Saying "choose 3" invokes
user.choose(3). Because the first item is typically already focused or requires zero movement to target, the action calculates the keystroke sequence as(number - 1)down arrow presses followed by anenter. For example,choose 3translates to sending the keysdowntwice and thenenter(down:2 enter). - Upward Selection: Saying "choose up 3" invokes
user.choose_up(3). This is useful when a menu opens upwards or when navigating backwards from the bottom of a list. It sendsuparrow presses equal to the specified number, followed by anenter(up:3 enter).