From: has Date: 2008-02-19T00:39:59+09:00 Subject: Re: Send keystrokes to Firefox or Safari? On 18 Feb, 00:41, Stedwick wrote: > Well, how about this: is there something like AutoIt for the Mac (if I > can control it with Ruby, so much the better)? > > I tried rb-appscript already, but I couldn't figure out how to send > keystrokes =P See: http://www.apple.com/applescript/uiscripting/index.html The sample scripts given there are written for AppleScript, obviously, but could be translated to Ruby with a little work. (Hint: ASDictionary and ASTranslate are your friends.) Example: #!/usr/bin/ruby begin; require 'rubygems'; rescue ImportError; end require 'appscript' include Appscript app('Safari').activate app('System Events').keystroke('Your text here') GUI scripting is crude and fragile, but can be useful when dealing with applications that don't provide a proper scripting API for the features you need. You can also script Safari directly, including executing your own JavaScripts via its 'do JavaScript' command. (This is what SafariWatir [http://safariwatir.rubyforge.org/] does.) Dunno about Firefox as I don't use it myself, but maybe someone else will know. HTH has -- http://appscript.sourceforge.net http://rb-appscript.rubyforge.org