Is there a proof-of-concept Objective-C executable that enters some text into an application and then clicks the mouse, using Apple events and not AppleScript?
e.g. the AppleScript equivalent of
tell application "System Events"
tell process "Safari"
keystroke "Hello World"
click
end tell
end tell
It should work on Mac OS X 10.9, preferably be future oriented (backwards compatibility doesn't matter). The context is that I will be calling the Objective-C code from another language.
I'm saying this because I read that:
As of Mac OS X 10.7, the low-level Cocoa API (NSAppleEventDescriptor) still lacks essential functionality (e.g. the ability to send Apple events), while the high-level Cocoa API (Scripting Bridge) is too flawed and limited to be a viable foundation for an appscript-style wrapper.
and:
NSAppleScript can safely be used only on the main thread
so, my goals are:
- any application (by name or if current)
- any keyboard input or mouse
- from C or Objective-C
- within a few hundred milliseconds
thanks!
I'm not sure if this is what you're looking for, but you may be interested in setting up an NSInvocation object:
If you're looking to run some code and 'simulate' a UX environment, it may be valuable to save an invocation and run it.
(Automator?)