Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pturpin
Copy link

@pturpin pturpin commented Sep 15, 2023

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.

pturpin and others added 2 commits September 15, 2023 14:22
#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.
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):
Copy link
Collaborator

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?

Copy link
Author

@pturpin pturpin Sep 18, 2023

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.

  1. Where the app title could contain one of two different things.
    focus outlook: user.switcher_focus_app_title("Outlook", "(Inbox|Calendar)")

  2. When I don't want the title to contain a specific string.
    focus studio: user.switcher_focus_app_title("Microsoft Visual Studio", "^(?:(?!Application Management).)*$")

Copy link
Collaborator

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?

Copy link
Collaborator

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.

@knausj85 knausj85 added the to discuss To discuss in one of the meet-ups label Dec 7, 2024
@knausj85
Copy link
Member

knausj85 commented Dec 7, 2024

Continuing to go through old pull requests:
I think we need to take a moment to reevaluate this one in an upcoming community backlog session.
If we do move forward with is functionality, I do think it should be reimplemented using dynamic lists
#1621

@nriley
Copy link
Collaborator

nriley commented Dec 14, 2024

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.

@nriley nriley added help wanted Extra attention is needed and removed to discuss To discuss in one of the meet-ups labels Dec 14, 2024
@fidgetingbits
Copy link
Collaborator

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.

@nriley
Copy link
Collaborator

nriley commented Dec 16, 2024

AFAIK, dynamic lists are in public; [dynamic] selection lists are only in beta.

@lunixbochs
Copy link
Collaborator

lunixbochs commented Dec 16, 2024

you shouldn't detect beta, because there are more branches than just beta and public
also afaik dynamic lists are still in beta

@fidgetingbits
Copy link
Collaborator

AFAIK, dynamic lists are in public; [dynamic] selection lists are only in beta.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants