Hello fellow programmers!

I would like to save some applescript code as an application, so that when I open the application it will go to Google Chrome and answer an incoming call in Google Voice.

I will have my gmail account already open in the chrome browser, so all that is needed is for the applescript application to tell google chrome to activate, then click in a particular area (where the button will appear) to accept the call.

How can I find out the coordinates of where I want the mouse to click? Because I am making a separate application to click elsewhere and end the call.

Can anyone tell me how I would code this in applescript? or is there an easier way?

The following code is similar to something I found, and it works, but i'm not sure where/if it is clicking...

tell application "Safari" to activate
tell application "System Events"
   tell process "Safari"
   click at {300, 100} -- {from left, from top}
   end tell
end tell

Thank you for your time, -Sebastian

3 Answers 3


You can also click elements with JavaScript:

tell application "Google Chrome" to tell active tab of window 1
    execute javascript "document.getElementById('chrome-web-store-title').click()"
    --execute javascript "document.querySelectorAll('.tile-grid .most-visited')[3].click()"
end tell

Focusing an existing tab by URL:

tell application "Google Chrome"
    repeat with w in windows
        set i to 1
        repeat with t in tabs of w
            if URL of t starts with "https://mail.google" then
                set active tab index of w to i
                set index of w to 1
            end if
            set i to i + 1
        end repeat
    end repeat
end tell
  • 6
    Hello from 7 years in the future! These days, if you want to run Javascript in Chrome, you'll need to go to View > Developer > Allow JavaScript from Apple Events. See: support.google.com/chrome/?p=applescript
    – Leland
    Commented Sep 14, 2020 at 22:50

It looks like it's clicking 300 pixels right, and 100 pixels down from the top left corner. (I'm not sure if that's the top left corner of the screen or of the Safari window...) You can find out where that is by pressing Shift-Command-4, then moving the cross hair until the top number is 300, and the bottom number is 100. You can get rid of the cross hair by pressing escape. Then you can work out where you'd really like the script to click, and change the numbers in the script to match.

  • 1
    Thank you for that shortcut, daviewales! Only issue is that clicking only seems to work within the realms of the BROWSER itself... as in, I can click and open a new tab, click file, refresh button, but NOT any button on the actual website. Any solutions?
    – seba1685
    Commented Feb 7, 2013 at 1:06
  • I just tested it, and I found that I could make it click on emails in Gmail, and buttons on the Google home page, but I couldn't make it click on any of the buttons in the Google Talk window.
    – daviewales
    Commented Feb 7, 2013 at 2:17

It's easy,you can do it in five steps!

  1. open applescript editor

  2. click Record

  3. open Finder and activate Google Chrome

  4. click Stop or the circle with a hexagon in front of it

  5. press Cmd+S and a window will appear - save your script as an application and click the circle with the words "start-up" next to it

Epilogue: restart your Mac and watch Chrome appear like magic!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .