Drag to convert Automator Action into Applescript
In Automator, there is a way to quickly convert an Action into its equivalent Applescript in Automator, I think by dragging it in some tricky way. I saw this some time ago but have now forgotten. I've tried searching and can't find it.
Solution 1:
In case anyone has this question, I found it, but it only works for recorded actions.
After you Record some clicks or other actions in Automator, they appear in a "Watch Me Do" action. You can then click on and drag an individual action out of that Action and release when the + sign appears. Automator will add a "Run AppleScript" action with the AppleScript that sends the same clicks and key presses to System Events.
You can also simply Copy the action you want, switch over to AppleScript Editor, and paste to get the same code.
Example: "Click Skype in the Dock" Event converts to the following AppleScript:
on run {input, parameters}
-- Click “Skype” in the Dock.
delay 7.872251
set timeoutSeconds to 2.000000
set uiScript to "click UI Element \"Skype\" of list 1 of application process \"Dock\""
my doWithTimeout( uiScript, timeoutSeconds )
return input
end run
on doWithTimeout(uiScript, timeoutSeconds)
set endDate to (current date) + timeoutSeconds
repeat
try
run script "tell application \"System Events\"
" & uiScript & "
end tell"
exit repeat
on error errorMessage
if ((current date) > endDate) then
error "Can not " & uiScript
end if
end try
end repeat
end doWithTimeout
How to convert recorded events in Automator: