Skip to content

Add capability to focus window by title#1262

Open
pturpin wants to merge 2 commits into
talonhub:mainfrom
pturpin:pturpin/focus-by-title
Open

Add capability to focus window by title#1262
pturpin wants to merge 2 commits into
talonhub:mainfrom
pturpin:pturpin/focus-by-title

Conversation

@pturpin

@pturpin pturpin commented Sep 15, 2023

Copy link
Copy Markdown

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
Copy Markdown
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?

@pturpin pturpin Sep 18, 2023

Copy link
Copy Markdown
Author

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
Copy Markdown
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
Copy Markdown
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

knausj85 commented Dec 7, 2024

Copy link
Copy Markdown
Member

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

nriley commented Dec 14, 2024

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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

nriley commented Dec 16, 2024

Copy link
Copy Markdown
Collaborator

My comment here was wrong, dynamic lists are not in public. I was confused because the method was defined but trying to use it results in an error. On 0.4.0:

>>> from talon import Context
>>> x = Context()
>>> x.dynamic_list
<bound method Context.dynamic_list of Context(repl)>
>>> x.dynamic_list('user.foo')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "talon/scripting/context.py", line 464, in dynamic_list
NotImplementedError

@lunixbochs

lunixbochs commented Dec 16, 2024

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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