-
Notifications
You must be signed in to change notification settings - Fork 855
Add shortcat integration #1940
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
base: main
Are you sure you want to change the base?
Add shortcat integration #1940
Changes from 4 commits
3a47c6e
61bc6f2
f550022
4a27a2f
2ea8caf
3fdee19
a731154
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| from talon import Module, actions | ||
|
|
||
| mod = Module() | ||
|
|
||
| # Hotkey that is configured to activate Shortcat | ||
| SHORTCAT_HOTKEY = "cmd-shift-space" | ||
| # Delay to wait for Shortcat to show the shortcuts | ||
| SHORTCUTS_DELAY = "500ms" | ||
|
|
||
|
|
||
| @mod.action_class | ||
| class Actions: | ||
| def shortcat_hover(text: str): | ||
| "Hover over a button using shortcat" | ||
| actions.key(SHORTCAT_HOTKEY) | ||
| actions.sleep(SHORTCUTS_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) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
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) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| ^(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") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a setting so it can be changed by users without modifying the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced both constants with settings