I have found this code for an Autoclicker on macOS using QuartzEvents to post the click events but it only works if I turn the sandboxing off. Is there a way to simulate a mouse click with sandboxing on?
var mouseLoc = NSEvent.mouseLocation()
mouseLoc.y = NSHeight(NSScreen.screens()![0].frame) - mouseLoc.y
let point = CGPoint(x: mouseLoc.x, y: mouseLoc.y)
let mouseDown = CGEvent(mouseEventSource: nil, mouseType: .leftMouseDown, mouseCursorPosition: point, mouseButton: .left)
let mouseUp = CGEvent(mouseEventSource: nil, mouseType: .leftMouseUp, mouseCursorPosition: point, mouseButton: .left)
mouseDown?.post(tap: .cghidEventTap)
mouseUp?.post(tap: .cghidEventTap)