Automator not recording keystrokes (keyboard shortcuts)

I am trying to get automator to record the following keyboard shortcuts:
command option+ctrls
and then
ctrl shifteject

any ideas on how to get automator to capture these and or another way to automate this process?

Macbook, Mac OS X (10.6)

Posted on Nov 6, 2009 6:55 PM

Reply
13 replies

Nov 6, 2009 7:05 PM in response to Matty G

don't use automator record action for this. you can simulate the first one with applescript if need be. the second one is the shortcut to sleep display. what exactly are you trying to do? there is likely a better way to do it. recording things with automator should be the option of absolutely last resort if nothing else works.

Nov 6, 2009 8:20 PM in response to Matty G

ok, so you've installed Insomina X. as I understand it, it keeps your computer awake even if you close the lid. if I understand you correctly you want to start insomnia x, close the lid and then put the display to sleep, right?
I'm not sure why you need a keyboard shortcut to launch insomnia x if you are going to be calling it from automator. just let automator execute the action
"launch application" and add insomnia x" to that action. for putting the display to sleep I would suggest using this app
http://www.macupdate.com/info.php/id/26234/sleep-display

again you can call it from automator using "launch application" action.

Nov 6, 2009 8:41 PM in response to Matty G

ah, ok. but you say you created a shortcut (ctrl opt+coms) to enable insomnia once it loads, is this right? sorry, this is not something I ever used so I'm not sure how it's organized.

if this is correct then you can simulate those keystrokes with applescript as follows.


tell application "InsomniaX" to activate
tell application "System events" to keystroke "s" using {command down, control down, option down}



you can embed it into an automator workflow using "run applescript" action


on run {input, parameters}

tell application "InsomniaX" to activate
tell application "System events" to keystroke "s" using {command down, control down, option down}
end run

Nov 6, 2009 9:54 PM in response to Matty G

so I have changed my keyboard shortcut and I am using the following code:

on run {input, parameters}

tell application "InsomniaX" to activate
tell application "System Events" to key code 51 using {shift down, control down}
tell application "SleepDisplay" to activate

end run

However I am now getting an error saying that Sleep display isnt running, however it does work. Is there anyway to fix this or subdue the error

Nov 6, 2009 10:09 PM in response to Matty G

I'm not sure what's going on. try inserting a delay. maybe the commands fire two fast.


on run {input, parameters}
tell application "InsomniaX" to activate
tell application "System Events" to key code 51 using {shift down, control down}
delay 1
try
tell application "SleepDisplay" to activate
end try
end run


P.S. you can also use "try... end try" as above. that should probably kill the error message.

BTW, red menace made a very good point about carrying your laptop around with the hard drive spinning. that's not a great idea.

Message was edited by: V.K.

Nov 6, 2009 10:54 PM in response to V.K.

this 'try' bit fixed it.

thanks so much.

If anyone else is looking for the final script that works:

on run {input, parameters}

tell application "InsomniaX" to activate
tell application "System Events" to key code 51 using {shift down, control down}
delay 1
try
tell application "SleepDisplay" to activate
end try
tell application "System Events" to key code 51 using {shift down, control down}

end run

with insomniaX having a hotkey of ctrl shiftdelete

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automator not recording keystrokes (keyboard shortcuts)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.