diff --git a/src/command.py b/src/command.py index 1b0111a..eb74b78 100644 --- a/src/command.py +++ b/src/command.py @@ -23,6 +23,7 @@ def rango_command_without_target( actionType: str, arg: Union[str, float, None] = None, arg2: Union[str, None] = None, + arg3: Union[bool, None] = None, ): """Executes a Rango command without a target""" action = {"type": actionType} @@ -30,4 +31,6 @@ def rango_command_without_target( action["arg"] = arg if arg2: action["arg2"] = arg2 + if arg3: + action["arg3"] = arg3 return actions.user.rango_run_command(action) diff --git a/src/rango.py b/src/rango.py index 951a250..048129f 100644 --- a/src/rango.py +++ b/src/rango.py @@ -10,7 +10,9 @@ def rango_hint_double(m) -> str: return m.letter + m.letter -@mod.capture(rule=" | | ") +@mod.capture( + rule=" | | " +) def rango_hint(m) -> str: return "".join(m) @@ -63,6 +65,14 @@ def rango_run_action_on_reference(command: str, reference: str): "runActionOnReference", command, reference ) + def rango_run_action_on_text_matched_element( + command: str, text: str, prioritize_viewport: Union[bool, None] = False + ): + """Runs a Rango command on a hintable element found using fuzzy search""" + actions.user.rango_command_without_target( + "runActionOnTextMatchedElement", command, text, prioritize_viewport + ) + def rango_get_bare_title() -> str: """Returns the title of the currently focused tab without including the decorations""" return actions.user.rango_command_without_target("getBareTitle") diff --git a/src/rango.talon b/src/rango.talon index 6e58158..f5ef079 100644 --- a/src/rango.talon +++ b/src/rango.talon @@ -73,6 +73,10 @@ dismiss: user.rango_command_without_target("unhoverAll") show : user.rango_command_with_target("showLink", rango_target) +# Hide hint +hide : + user.rango_command_with_target("hideHint", rango_target) + # Scroll upper: user.rango_command_without_target("scrollUpPage") upper : user.rango_command_without_target("scrollUpPage", number) @@ -230,6 +234,7 @@ rango open {user.rango_page}: user.rango_command_without_target("openPageInNewTa # Hint/element references for scripting mark as : user.rango_command_with_target("saveReference", rango_target, word) +mark this as : user.rango_command_without_target("saveReferenceForActiveElement", word) mark show: user.rango_command_without_target("showReferences") mark clear : user.rango_command_without_target("removeReference", word) @@ -238,5 +243,15 @@ click mark : user.rango_run_action_on_reference("clickElement", word) focus mark : user.rango_run_action_on_reference("focusElement", word) hover mark : user.rango_run_action_on_reference("hoverElement", word) +# Run action by matching the text of an element +follow : + user.rango_run_action_on_text_matched_element("clickElement", text, true) +button : + user.rango_run_action_on_text_matched_element("clickElement", text, false) +focus text : + user.rango_run_action_on_text_matched_element("focusElement", text, true) +hover text : + user.rango_run_action_on_text_matched_element("hoverElement", text, true) + rango explicit: user.rango_force_explicit_clicking() rango direct: user.rango_force_direct_clicking() \ No newline at end of file diff --git a/src/talon_helpers.talon b/src/talon_helpers.talon index f6e8212..f2a1b81 100644 --- a/src/talon_helpers.talon +++ b/src/talon_helpers.talon @@ -1,6 +1,13 @@ code.language: talon - -# Helpers to make scripting using references easier +# Helpers to make scripting easier + +# Using references click rango mark : "user.rango_run_action_on_reference(\"clickElement\", \"{word}\")" focus rango mark : "user.rango_run_action_on_reference(\"focusElement\", \"{word}\")" hover rango mark : "user.rango_run_action_on_reference(\"hoverElement\", \"{word}\")" + +# Using fuzzy search with the text of the element +click rango text : "user.rango_run_action_on_text_matched_element(\"clickElement\", \"{text}\")" +focus rango text : "user.rango_run_action_on_text_matched_element(\"focusElement\", \"{text}\")" +hover rango text : "user.rango_run_action_on_text_matched_element(\"hoverElement\", \"{text}\")" \ No newline at end of file