Question: This code works to click on a specific location on the screen but how do you click at the cursor's coordinates?

```
tell application "System Events"
    click at {10, 10}
end tell

```

Answer: 
```
    use framework "Foundation"

    property NSEvent : a reference to current application's NSEvent
    property NSScreen : a reference to current application's NSScreen

    # Get display size
    set display to NSDeviceSize ¬
        of deviceDescription() ¬
        of item 1 ¬
        of NSScreen's screens() as record

    # Get mouse location (relative to the bottom-left of the screen)
    set mouseLocation to {x, y} of (NSEvent's mouseLocation as record)

    # Calculate mouse y-coordinate so it's relative to the top of the screen
    set mouseLocation's item 2 to (display's height) - (mouseLocation's item 2)

    tell application "System Events" to click at the mouseLocation

```
I created a command line tool in Xcode using the Swift programming language to produce an executable:

```
    // Location of Mouse pointer
    var ml = NSEvent.mouseLocation
    ml.y = NSHeight(NSScreen.screens[0].frame) - ml.y
    let location = CGPoint(x: ml.x, y: ml.y)

    // Single mouse click.
    var e = CGEvent(mouseEventSource: nil, mouseType: .leftMouseDown, mouseCursorPosition: location, mouseButton: .left)!
    e.post(tap: .cghidEventTap)
    e = CGEvent(mouseEventSource: nil, mouseType: .leftMouseUp, mouseCursorPosition: location, mouseButton: .left)!
    e.post(tap: .cghidEventTap)

    e = CGEvent(mouseEventSource: nil, mouseType: .leftMouseDown, mouseCursorPosition: location, mouseButton: .left)!
    e.setIntegerValueField(.mouseEventClickState, value: 1)
    e.post(tap: .cghidEventTap)

    e = CGEvent(mouseEventSource: nil, mouseType: .leftMouseUp, mouseCursorPosition: location, mouseButton: .left)!
    e.setIntegerValueField(.mouseEventClickState, value: 1)
    e.post(tap: .cghidEventTap)

```

I then created a shell script in Script Editor to trigger the executable:

```
do shell script "/Users/bobby/Documents/AppleScripts/Mouse/Executables/Click"

```

Change the location based on where you saved the executable.