我正在创建一个移动鼠标光标并执行左右单击的软件。我移动了光标,但不能执行左键单击。我在做什么错了?
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)