Is it possible to use mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure: in AppleScriptObjC and how?
I would like to replace snippets of code in one of my libraries that uses system event’s click at method.
Jonas. I found a thread with a post by Shane on this topic (here). I tried several variations of the following but none appeared to do anything.
use framework "AppKit"
use framework "Foundation"
set theEvent to current application's NSEvent's mouseEventWithType:(current application's NSLeftMouseDown) location:{x:20, y:20} modifierFlags:0 timestamp:0 windowNumber:0 context:(missing value) eventNumber:0 clickCount:1 pressure:1.0
BTW, Shane makes the following comment, and I’m not sure what this means.
But I don’t know how you dispatch it to another application.
The code you posted creates an event, but it still has to be sent to an app’s event queue for anything to happen. That can be done with NSApplication’s sendEvent: or postEvent:AtStart: methods, but you can only call them on your own application’s NSApplication instance.
I’m calling it from within InDesign by the do script command.
The issue is not the current application here but the fact that the origin point is bottom-left.
What stupid I am!