Mouse Clicks in Applescript

Hello all:

I am relatively new to the Mac and brand new to Applescript, but I am attempting to write a script that will go to a database website, log in using my username and password, and then search according to my specified parameters and download some data. I’ve been learning by doing and have found most of the commands I need to make this script work, however no where online can I find the command for how to tell Applescript to click the mouse in a particular location. The best I’ve found is the command: click at {1,1}, which seems to click the mouse at the top left corner of the screen, but I don’t have any perspective on the coordinates or how wide each coordinate unit is so that I can tell it to click in other locations on the screen.

Can anyone give me a one paragraph summary of how to tell Applescript to click the mouse in a particular location? Thanks.

Check out this post.



Excellent! Using apple-shift-4 to see the coordinates and then using: click at {x,y} solves the problem, except that it won’t work for radio buttons on websites. Any idea why?


it looks like a more reliable solution is using javascript instead of poking around with UI scripting and coordinates.
For an example take a look at this thread

Alright, I may have to break down and learn a bit of javascript to tackle this problem, but I’ve had the same problem with clicking any buttons on webpages as well. Essentially, unless the “click at” command is directed to a hyperlink, it won’t work. This applies to normal buttons on websites (like submit or login) as well as to radio buttons. For example, I wrote a quick script to automatically login to my account on this forum, and while I could use the keystroke command to have the script type in my username and password, using click at on the “login” button would not work. Any suggestions? Thanks!

There is no common solution, because the code of every website can be different.

UI scripting and using the javascript capabilities in Safari is a lot of trial & error :wink: