0

我正在创建一个移动鼠标光标并执行左右单击的软件。我让光标移动了,但我无法执行左键单击。我究竟做错了什么?

let point = CGPoint(x:366, y:528) // Random point
    self.moveCursor(point: point)

    // click mouse
    let eventMouseDown = CGEvent(mouseEventSource: nil, mouseType: 
      .leftMouseDown, mouseCursorPosition: point, mouseButton:.left)
    eventMouseDown?.post(tap: .cghidEventTap)

    // release mouse
    let eventMouseUp = CGEvent(mouseEventSource: nil, mouseType: 
      .leftMouseUp, mouseCursorPosition: point, mouseButton: .left)
     eventMouseUp?.post(tap: .cghidEventTap)
4

0 回答 0