2

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)
mahal tertin
  • 3,239
  • 24
  • 41
  • What are you trying to achieve? There might be other ways to achieve your goal within sandbox and appropriate entitlements. – mahal tertin May 14 '18 at 08:47
  • I want to build an autoclicker and I have seen that there are some clickers already on the store. I am trying to simulate the mouse click with QuartzEvents but unfortunately it doesn't work as long as app sandboxing is enabled. – Lucian Boiangiu Jun 18 '18 at 14:48
  • I doubt that the autoclicker you found in AppStore is sandboxed. There was a time when this wasn't needed. https://stackoverflow.com/questions/22751171/mac-app-store-circumvent-sandbox-requirement/22761542#22761542 – mahal tertin Jun 18 '18 at 15:30

1 Answers1

0

Sorry to say but that's not possible. The purpose of sandbox is to limit your app not to interfere with other apps.

mahal tertin
  • 3,239
  • 24
  • 41