Skip to content

Added --window option to target keypresses at a specific window.#101

Open
hugomallinson wants to merge 1 commit intosocsieng:mainfrom
hugomallinson:main
Open

Added --window option to target keypresses at a specific window.#101
hugomallinson wants to merge 1 commit intosocsieng:mainfrom
hugomallinson:main

Conversation

@hugomallinson
Copy link
Copy Markdown

Here's a way of sending keypresses only to a specific window. It works by focusing the right window within the application before sending the keypresses. It may run into problems with apps that override window focus or event handling.

I've made the --window argument restrictive, so if it doesn't find a matching window it won't send the event.

It does a startsWith match instead of a complete match. My use case is for PowerPoint slide shows, and those windows are always titled "PowerPoint Slide Show – File Name.pptx", so this lets you do

sendkeys send --targeted -a com.microsoft.Powerpoint --no-activate --window "PowerPoint Slide Show" -i 0 -c "<c:pgdown>"

@hugomallinson hugomallinson mentioned this pull request Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant