Jump to content
Mike

Feature Request: Simulate Key presses in Workflows

Recommended Posts

Hmmm, there is no way to simulate the eject key in AS? :-/

Rather than create a workflow for such a basic function, why not just install Dockables, and then "Sleep Display" becomes an app which can be immediately launched from Alfred anyway. That's what I use for doing precisely this.

 

Or you could just reassign the hotkey and use AS.

Share this post


Link to post
Share on other sites

Is there a way to simulate keypress in other languages like python?

 

Not that I'm aware of, but my knowledge of Python isn't very extensive. You could however use some of Python's other modules to perform system actions and execute Applescript using osascript from the command line

Share this post


Link to post
Share on other sites

Thanks David.

 

I figured out how to call simple applescripts from Python:

from subprocess import Popen, PIPE
 
def run_this_scpt(scpt, args=[]):
     p = Popen(['osascript', '-'] + args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
     stdout, stderr = p.communicate(scpt)
     return stdout
 
#Example of how to run it.
run_this_scpt("""tell application "System Events" to keystroke "m" using {command down}""")
 
#Example of how to run with args.
run_this_scpt('''
    on run {x, y}
        return x + y
    end run''', ['2', '2'])

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...