Jump to content

A workflow-action for keystrokes and mouse


Recommended Posts

It will be great if workflows have a Send keystrokes as an output action, to simulate key pressing.


This can facilitate workflows that acts as macros or autocompletion


Right now, when I need to return (write, keypress) certain value I must use this osascript


tell application "System Events"
    key down return
    keystroke "output value: "
    keystroke "{query}"
end tell
But this solution isn't so elegant and tends for lag.
I know that modern text editor used to have this kind of features; but a keystroke action provides a generic & direct tool to control the system.
You may agree that sometimes the Automator can't reach your desired option.
Another output action can simulate mouse actions.
This tool can simulate different type of mouse actions: clicks, drags, movements, etc
Currently I'm using this tools to automate repetitive task like
- Replace/filter strings
- Type down values (for keyboard keys)
- Take screenshots of the screen around the cursor
I hope that some of this stuff make sense for you.
Link to comment
Share on other sites

  • 2 weeks later...

Let me insist with this topic


Someone may say that the Copy to clipboard action is what I could use.. since there is a template 'Clipboard > Paste as plain text / text clip from hotkey'

But it's inaccurate. Because even when this action can paste a text on any app, it comes from a copy to clipboard action that replaces your current clipboard value :(


What I'm asking is a straightforward action to type the text or keystrokes.

Link to comment
Share on other sites

  • 1 year later...

Add me to this request. One thing I want to use this for is running applications out of VMware Fusion where the same HotKey I use to make Alfred start the application is passed to the application itself to do its work (in this case bring up a sub-window).


Passing keystrokes would be handy.



Link to comment
Share on other sites

  • 3 months later...

If I want to enter keystrokes via a hotkey, how do you clear the hotkey before it gets to the script?


In other words, if I set up a script to type some text using "keystroke", whatever modifier keys I held down to trigger the script affect the output... So, if my hotkey is Cmd + Shift + (whatever), the result doesn't work as the first thing that gets 'typed' by system events is Cmd+Shift+first letter of what you wanted to type, followed by Cmd+Shift+second letter, etc.

How do I stop the hotkey modifiers getting passed through to the script output?

I don't want to do this with snippets, as I don't want to change or use the clipboard.

Link to comment
Share on other sites

  • 2 weeks later...

How do I stop the hotkey modifiers getting passed through to the script output?

I'm afraid the bottom line is: take your fingers off the keys.


The whole point of keystroke is to appear exactly like real keypresses to the receiving application. If you've got your finger on the ⌘ key, then that gets sent along with your keystroke command and there's nothing AppleScript can do about that.

If you're using Alfred's Hotkeys, open your Hotkey Settings, right-click on the Hotkey field, and select "Wait until modifier keys are released" from the Trigger behaviour menu. That way, nothing gets run till you let go of the modifiers.

If that's not good enough for you (it's obviously a lot slower), you might want to look for an application that lets you set fn as a modifier: it's far less likely to turn a keystroke into a keyboard shortcut.

Edited by deanishe
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...