reference to current application is NOT foreground application

I have a property:
property NSApplication : a reference to current application’s NSApplication
If my applescriptobjc script is run NSApplication is set to the application that ran the script and not the frontmost application. I want the script to be run from a background application while Xcode is the frontmost application but still have NSApplication set to Xcode. How can I change the property to point to Xcode? Remember this is an Applescriptobjc script.

NSApplication is the name of a Cocoa class, and you use it by prepending it with current application. Don’t try setting it to anything else.

So there’s no way to have an ApplescriptObjC script run via Keyboard Maestro macro on a specific application? It sounds like your saying that current application will be Keyboard Maestro which really sucks. I need to get the class of the first responder of Xcode.

Thanks for your help

Correct. ASObjC can only target objects within the application hosting the script. To interact with another application, you’ll need to use AppleEvents.

Thanks for the bad news:(