I am trying to simulate mouse click on iphone simulator from macos App for that I am using CGEvents .
the process id is 33554 for iPhone simulator
let point = CGPoint(x: 500 , y:300)
let eventMouseDown = CGEvent(mouseEventSource: nil, mouseType: .leftMouseDown, mouseCursorPosition: point, mouseButton: .left)
let eventMouseUp = CGEvent(mouseEventSource: nil, mouseType: .leftMouseUp, mouseCursorPosition: point, mouseButton: .left)
eventMouseDown?.postToPid(33554)
eventMouseUp?.postToPid(33554)
I have also noticed that It simulates mouse click when ios simulator window is focused and only works for this toolbar but not for the simulator for example if I change CGPoint to (0,30) it will click on Simulator option
but when I am giving CGPoints to click app inside iOS Simulator its not working
However, I am able to post Keyboard Event to Simulator using
let keyboardDown = CGEvent(keyboardEventSource: nil, virtualKey: 6, keyDown: true)
let keyboardUp = CGEvent(keyboardEventSource: nil, virtualKey: 6, keyDown: false)
keyboardDown?.postToPid(33554)
keyboardUp?.postToPid(33554)