Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions apps/shortcat/shortcat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from talon import Module, actions, settings

mod = Module()

mod.setting(
"shortcat_hotkey",
type=str,
default="cmd-shift-space",
desc="Hotkey that is configured to activate Shortcat",
)
mod.setting(
"shortcat_click_delay",
type=str,
default="500ms",
desc="Delay to wait for Shortcat to show the shortcuts before clicking",
)


@mod.action_class
class Actions:
def shortcat_hover(text: str):
"Hover over a button using shortcat"
actions.key(settings.get("user.shortcat_hotkey"))
actions.sleep(settings.get("user.shortcat_click_delay"))
actions.insert(text)

def shortcat_click(text: str, click_delay: str = "0ms"):
"Click a button using shortcat"
actions.user.shortcat_hover(text)
actions.sleep(click_delay)

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.

From the community backlog session, we had a couple comments on this behavior.

If the delay is to give you time to cancel if the wrong button is about to be clicked, then using actions.sleep will block Talon and not allow you to cancel using a voice command or other Talon action. A couple options:

  • Having a separate confirmation action. This is how my Homerow support works
  • Using cron such that Talon is active while it is waiting.

Our preference is for the first option as we feel that any substantial delay long enough to give you a chance to cancel would be frustrating to use in practice.

actions.key("enter")
actions.sleep("100ms")
actions.mouse_click(0)

def shortcat_double_click(text: str, click_delay: str = "0ms"):
"Double click a button using shortcat"
actions.user.shortcat_hover(text)
actions.sleep(click_delay)
actions.key("enter")
actions.sleep("100ms")
actions.mouse_click(0)
actions.mouse_click(0)

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.

Consider using a single action for single and multiple clicks.


def shortcat_right(text: str, click_delay: str = "0ms"):
"Right click a button using shortcat"
actions.user.shortcat_hover(text)
actions.sleep(click_delay)
actions.key("ctrl-enter")
16 changes: 16 additions & 0 deletions apps/shortcat/shortcat.talon
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
os: mac
-

^(shot | sot) [<user.text>]: user.shortcat_hover(text or "")

^(shot | sot) click [<user.text>]:
# Add some delay to cancel click if needed
user.shortcat_click(text or "", "1500ms")

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 that this delay would be incredibly frustrating in practice, not to mention it is likely to trigger Talon's watchdog timer and spam your log. I would recommend that you have this as a configurable setting, if you decide to use the cancel delay rather than a confirmation action.


^(shot | sot) right [<user.text>]:
# Add some delay to cancel right-click if needed
user.shortcat_right(text or "", "1500ms")

^(shot | sot) dub [<user.text>]:
# Add some delay to cancel double-click if needed
user.shortcat_double_click(text or "", "1500ms")