I am making a service in Automator that runs the following AppleScript code:
on run {input, parameters}
tell application "System Events"
click at {393, 77}
delay 0.1
keystroke "Hello"
delay 0.1
keystroke return
end tell
return input
end run
If you couldn't tell, I'm trying to click on something and type "Hello" there. However, when I run this, all that happens is I hear the "plunk" sound when you do something invalid, twice. Why isn't this code working?
The log does say "Run AppleScript completed" and then "Workflow completed."
I have it set to run with no input on any application.
I tried increasing the delays, but that didn't help.
Let me know if there's any more details I can provide.
click at
function doesn't actually simulate a system mouse click, it appears more to trigger anAXPress
action associated with the object underneath the cursor at the time. Therefore, it will appear to click menu items and buttons, as those objects have this action programmed into them; but it would, for example, put focus onto a text field. Your code is fine - but it's just expectingclick at
to do something it cannot do.