11 lines
474 B
Swift
11 lines
474 B
Swift
|
|
import Cocoa
|
||
|
|
let p = CGPoint(x: 849, y: 707)
|
||
|
|
let before = CGEvent(source: nil)?.location ?? .zero
|
||
|
|
print("before: \(before)")
|
||
|
|
let mv = CGEvent(mouseEventSource: nil, mouseType: .mouseMoved, mouseCursorPosition: p, mouseButton: .left)
|
||
|
|
if mv == nil { print("CGEvent creation FAILED") }
|
||
|
|
mv?.post(tap: .cghidEventTap)
|
||
|
|
usleep(400_000)
|
||
|
|
let after = CGEvent(source: nil)?.location ?? .zero
|
||
|
|
print("after: \(after)")
|
||
|
|
print(mv == nil ? "NO PERMISSION TO CREATE?" : "event created ok")
|