I'm having a stroke with CGEvents and simulated input - please help

Anyone here happened to mess with the Quartz Event Services API ? I'm having a hard time trying to simulate input to a particular app. My goal is to achieve a simulated click input at any coordinates in a target app's window, if possible even if it is in the background (not foremost). The purpose of this is to have an automated custom routine running on an app in the background without hindering mouse movements and clicks. Apparently the Quartz Event Services API is the best option for that. Using CGEvent().post() works pretty well, but since I'm trying to target a particular app, i'd prefer to use CGEvent().postToPID(). Also CGEvent().post moves the mouse to the click's position, making it unfit for my problem. The problem is, the postToPID method doesn't work correctly ( or doesn't seem to at least). Any CGEvent mouse click posted with it only works if its coordinates are over the menu bar. Unfortunately, the postToPID method doesn't have any documentation, which makes doubtful about if it even is supposed to work. I also did a bunch of shenanigans trying to make it work : - tried using NSEvent : *not working *- it seems you can't send an NSEvent to an external app - tried using AppleScript : not working on 3rd party apps with an incompatible ui - tried listening to the events posted by post() and replicating their values manually : not working - even using the exact same event configuration and mouse event types with postToPID did not trigger a mouse click - tried listening to the events generated by an actual mouse click and programmatically replicating them (using CGEvent.copy()) : did not work - tried moving the mouse at the exact coordinates as the click - maybe the mouse had to be at the same point to work ( even though postToPID works on the menu bar without the mouse at the same spot) : did not work If you have any idea or solution I'd by happy to hear it! I've already spent 30+ hours on it, won't stop 'till I'm sure its not possible.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server