How do you write the command to carry out a double click with a mouse at a specific location in AppleScript?
2 Answers
You can use AppleScript to click twice using click at
and a delay.
tell application "System Events"
click at {10, 10}
delay 0.1
click at {10, 10}
end tell
-
-
1@Ian The dictionary says "in global coordinates"; not quite sure what this translates to, as {10, 10} is definitely not 10 pixels in on my retina display, but may be on a non-retina display (don't have one to test on)?– grg ♦Commented Jun 7, 2014 at 16:17
-
1Testing this (I'm on rMBP as well) results in the following:
error "System Events got an error: Can’t make {10, 10} into type list." number -1700 from {10, 10} to list
– njbootCommented Jun 8, 2014 at 0:56 -
Thanks for your help. I want to open an application called UVIWorkstation and you have to double click on an input window to open the browser. I can find the coordinate position in pixels and I want to double click on this position. The code tell application "UVIWorkstation" click at {455, 149} delay 0.1 click at {455, 149} end tell produces the error Commented Jun 9, 2014 at 15:06
-
1There was a bug with
click at
on Mavericks. It works again on Yosemite. Commented Oct 17, 2014 at 17:03
I'm afraid, double clicks no longer work if you run "El capitan"...
System Events' sdef file says "click at"s must be sent to a process object. This certainly includes buttons, menus, their items & some others, but not even (e.g.) objects visible on your desktop ...
As clicks on UI elements usually demand only one click, double clicks seem to be obsolete in AppleScript (for now).