Hi Bryan,
I've done this in the past using quick and dirty NSApplescript:
def
applescript_exec(script_string)
pnt =
Pointer.new_with_type("@")
as =
NSAppleScript.alloc.initWithSource(script_string)
as.executeAndReturnError(pnt)
end
script_string = %{
tell application "System
Events"
keystroke "h" using shift
down
end tell
}
applescript_exec(script_string) #
results in 'H'
You can send special keystrokes using this method also, see
https://discussions.apple.com/thread/660394?start=0&tstart=0
I think that the 'proper' way would be the Quartz method, but I've never
delved into that:
http://developer.apple.com/library/mac/#documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html#//apple_ref/c/func/CGEventCreateKeyboardEvent
fb
bryan rasmussen
04/07/2013 11:09
Hi,I've been
looking for examples as to how I might send keystrokes usingsystem.events
from macruby, but not finding anything.Anyone know of any, or
can give me an example script so I can get a start.Thanks,Bryan
Rasmussen___MacRuby-devel
mailing listMacRuby-devel@lists.macosforge.orghttps://lists.macosforge.org/mailman/listinfo/macruby-devel
___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macruby-devel