Click and Type Applecript code not working 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.
I would suggest downloading AppleScript toolbox scripting addition.  Once installed in the proper locations, in Script Editor.app, , you will be able to use commands from the key and mouse suite from the AppleScript toolbox dictionary to…get, set, and click at mouse locations (coordinates)

Here is some sample code using commands from the AppleScript toolbox dictionary



EXAMPLE 1

set mousePointLocation1 to {745, 110} -- The Collapsed Menu
set mousePointLocation2 to {780, 340} -- TV Link In The Menu
set mousePointLocation3 to {885, 180} -- Apple TV 4K Icon

delay 1 -- For Demonstration Purposes
activate application "Safari"
delay 1 -- For Demonstration Purposes

AST click at mousePointLocation1 ¬
    number of clicks 1

delay 1 -- For Demonstration Purposes

AST click at mousePointLocation2 ¬
    number of clicks 1

delay 1 -- For Demonstration Purposes

AST click at mousePointLocation3 ¬
    number of clicks 1








EXAMPLE 2

-- For Demonstration Purposes
-- Gives Me Time To Put The Mouse Where I Want
delay 3

-- Gets Coordinates Of The Current Mouse Location
set currentMouseLocation to AST mouse point location

-- Mouse Click At Defined Location
AST click at currentMouseLocation ¬
    number of clicks 2 -- How Many Clicks






EXAMPLE 3

set mousePointLocation to {20.0, 20.0}

delay 1 -- For Demonstration Purposes

AST set mouse point location mousePointLocation ¬
    without holding mouse down

delay 1 -- For Demonstration Purposes

AST click at mousePointLocation ¬
    number of clicks 1