-
Notifications
You must be signed in to change notification settings - Fork 791
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
Add capability to focus window by title #1262
base: main
Are you sure you want to change the base?
Conversation
#Problem When an app has multiple windows focus just picks the first one it fights, which may not be the desired one, and there is not a great way to focus just the window you want. #Solution Add a new method, switcher_focus_app_title, to app_switcher.py that will focus the window whose title matches a given app name and a given regular expression. Also added a command to that will focus a window with a given spoken phrase. #Testing Verified working in current windows eleven environment.
for more information, see https://pre-commit.ci
and window.title != "" | ||
): | ||
# logging.warn(f'Checking Window: "{window.app.name}" window:"{window.title}" hidden: "{window.hidden}"') | ||
if regex is None or re.search(regex, window.title): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's your usecase for passing a regex here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I currently have two commands that utilize an actual regex vs a plain string.
-
Where the app title could contain one of two different things.
focus outlook: user.switcher_focus_app_title("Outlook", "(Inbox|Calendar)")
-
When I don't want the title to contain a specific string.
focus studio: user.switcher_focus_app_title("Microsoft Visual Studio", "^(?:(?!Application Management).)*$")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this seems reasonable given the use cases. @auscompgeek any objection or you think it's ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the use-case makes sense. I'm not sure we should make this the primary way, or indeed the only way, of focusing by title, as it'd be prone to user error – it's unclear from the action name that it takes a regex.
Continuing to go through old pull requests: |
From the community backlog session — we agreed that this seems like a useful feature to add to community but we would prefer that it's implemented in terms of dynamic lists as @knausj85 recommended. |
Pretty sure aegis recently(ish) said in slack he doesn't want community using dynamic lists atm as they are in beta only? Discussion was related to someone wanting my justfile stuff added to community. I'd personally be okay to see community use dynamic lists gated behind a beta flag, but will let someone else have that debate. I believe in that justfile discussion (or around the same time) it was noted you can detect beta programmatically, but then of course still need to maintain two versions of the logic until it hits public. |
AFAIK, dynamic lists are in public; [dynamic] selection lists are only in beta. |
you shouldn't detect beta, because there are more branches than just beta and public |
Could be I'm confused, but my justfile doesn't use selection list (?) and was the topic of the discussion, and iirc no public release since, so maybe @lunixbochs can confirm. |
Problem
When an app has multiple windows focus just picks the first one it fights, which may not be the desired one, and there is not a great way to focus just the window you want.
Solution
Add a new method, switcher_focus_app_title, to app_switcher.py that will focus the window whose title matches a given app name and a given regular expression. Also added a command to that will focus a window with a given spoken phrase.
Testing
Verified working in current windows eleven environment.