AppleScript Code to Click at Returned Coordinates?

Hello,

This Applescript returns coordinates of a specific UI element. Is there anyway to write another line of Applescript to use the returned coordinates for a mouse click? I know I could code to always click at the current location {944.5, 844.0}, but the UI may move around and the UI element my change locations. So the idea is to use the UI element ID to get the coordinates every time I launch the script, and then click.

tell application "System Events"
   tell process "DaVinci Resolve"
      tell checkbox 13 of group 1 of window "DaVinci Resolve by Blackmagic Design - 17.0.0" of application process "Resolve" of application "System Events"
         set p to position
         set s to size
      end tell
   end tell
end tell

set xCoordinate to (item 1 of p) + (item 1 of s) / 2
set yCoordinate to (item 2 of p) + (item 2 of s) / 2
return {xCoordinate, yCoordinate}

Result --> {944.5, 844.0}

I'm using Keyboard Maestro to accomplish the last step now:

1 Like

Hey Ernest,

Good job!

-Chris