I tried using "Watch Me Do" in Automator to insert text "AW" and "Return" in a Stickies note. It recorded the following (Events were "Type 'AW'" and "Press Return", the rest is the expansion into code):
-- Type 'AW'
delay 0.315949
set timeoutSeconds to 2.000000
set uiScript to "keystroke \"AW\""
my doWithTimeout( uiScript, timeoutSeconds )
-- Press Return
delay 2.538645
set timeoutSeconds to 2.000000
set uiScript to "keystroke \"
\" "
my doWithTimeout( uiScript, timeoutSeconds )
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
In System Preferences, Security & Privacy, Privacy I allowed Automator.app and Stickies.app to control my computer.
I saved the above example as a service and tried executing the service in an empty Stickies note. Nothing happened.
I'm new at trying to use Automator. This is such a simple action that I believe that I have misunderstood something.
If I add to the workflow an existing Automator action that launches the Stickies application, then "AW" does get inserted, followed by "Return".
Question How to create a simple keyboard macro with Automator? shows a much simpler Applescript that could be adapted to doing what I describe (I've done such) but I'm frustrated that my simple "Watch Me Do" doesn't work. What am I overlooking or not understanding?