为什么我不能单击鼠标左键?

时间:2018-07-15 10:14:00

标签: swift macos qmouseevent

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

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)

0 个答案:

没有答案