Post

Replies

Boosts

Views

Activity

How to simulate a mouse click on an iPad connected as an external display
Hello. What API or framework to use to simulate a mouse click on an iPad connected as an external display? An iPad connected to the Mac via USB in a mode "Linked keyboard and mouse". What is the way to simulate a mouse click at a specific coordinate at such a display? So far I tried to simulate a click with CGEvent like so if let eventDown = CGEvent(mouseEventSource: source, mouseType: .leftMouseDown, mouseCursorPosition: point, mouseButton: .left), let eventUp = CGEvent(mouseEventSource: source, mouseType: .leftMouseUp, mouseCursorPosition: point, mouseButton: .left) { eventDown.post(tap: .cghidEventTap) usleep(500_000) eventUp.post(tap: .cghidEventTap) } but it seems it does not work even on the main display. I set the point to the coordinate outside of the app window so that on a click another app should be focused but it does not happen on a simulated click. I also tried to find a way to get a mouse coordinate on the external screen with addLocalMonitorForEvents. If I listen for the event NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) { event in debugPrint("NSEvent.mouseLocation:", NSEvent.mouseLocation) return event } it only works when the cursor is on the main screen and stops reporting as soon as the mouse enters the iPad. So, any advice is welcomed on which direction I should look.
0
0
290
Sep ’24
What is the programmatic way to capture screen from a connected iOS device to the Mac?
What framework to use to capture screen of a device connected to the Mac in the way OBS or QuickTime Player does when an iOS device is connected to Mac via USB. I tried to list devices with AVFoundation and ScreenCaptureKit but only Mac camera, mic and displays are listed. When you select New Movie Recording in the QuickTime Player you can choose an Connected iPad or iPhone to record it's screan. Same with OBS. What is the way to do it in my own MacOS app?
2
0
643
Jul ’24
Handle key events in a PHContentEditingController for Cocoa Photo Editing Extensions
Hello. How to receive keyboard events in PHContentEditingController on macOS? When extension is active tapping any key will result in Funk sound. First i tried to override keyDown in my subclass of PHContentEditingController, which does nothing. I also tried override keyDown in my subclass of NSView for my subclass of PHContentEditingController. Then i followed instructions from WWDC "Advances in macOS Security" session and implemented Input monitoring permissions request via CGEvent.tapCreate which only partially works. My extension now listed in System security / Privacy / Input Monitoring but it's impossible to turn it on. On each attempt to enable system fires alert with request to relaunch the app but does nothing. When alert disappear extension persist unchecked. My goal is to provide keyboard shortcuts for various task in Photo Editing Extension. How i can achieve that?
0
0
520
May ’22