-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from talon import Module, ui, Context | ||
from talon.windows import ax as ax | ||
|
||
mod = Module() | ||
|
||
def get_every_child(element: ax.Element): | ||
if element.children: | ||
for child in element.children: | ||
yield child | ||
yield from get_every_child(child) | ||
|
||
ctx = Context() | ||
|
||
mod.list("dynamic_children", desc="List of children of the active window") | ||
|
||
@ctx.dynamic_list("user.dynamic_children") | ||
def dynamic_children() -> dict[str,str]: | ||
root = ui.active_window().element | ||
elements = list(get_every_child(root)) | ||
|
||
return {str(i.name): str(i.name) for i in elements} | ||
|
||
@mod.action_class | ||
class Actions: | ||
def focus_element_by_name(name: str): | ||
"""Focuses on an element by name""" | ||
root = ui.active_window().element | ||
elements = list(get_every_child(root)) | ||
for element in elements: | ||
if element.name == name or \ | ||
str(element.name).lower() == name: | ||
element.invoke_pattern.invoke() | ||
break | ||
else: | ||
print("Element not found") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
^access {user.dynamic_children}$: | ||
user.focus_element_by_name(dynamic_children) |