title: Swift 4: Simulating left click programmatically causes right click
body: <p>This is the code I'm using to simulate a left click, but every time I execute it, the menu associated with a right click comes up.
  How can I fix this?</p>
  
  <pre><code>func clickLeft() {
      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)
      usleep(500)
      mouseUp?.post(tap: .cghidEventTap)
  }
  </code></pre>