From: James Britt Date: 2010-04-15T06:07:06+09:00 Subject: Re: How to use AutoIt in Ruby Marvin G�lker wrote: > > Otherwise, stick to win32ole: > require "win32ole" > au3 = WIN32OLE.new("AutoItX3.Control") That's how I've used it. It's pretty straightforward. I typically ended up writing a few helper methods for some of the repetitive things that required sending multiple commands to autoitx, or just to make the main code cleaner. #---- example: sign in to library Web site --- require 'win32ole' def set_up @au3 = WIN32OLE.new "AutoItX3.Control" @au3.opt "WinTextMatchMode", 2 end # Yeah, it's kinda old ... def browse_to url @au3.Run "C:\\Program Files\\Mozilla Firefox2\\firefox.exe #{url}" end def enter @au3.Send "{ENTER}" end def tab send "{TAB}" end def wait n @au3.Sleep n.to_i end def send s warn s @au3.Send s.to_s end def wait_for_title t @au3.WinWaitActive t.to_s end #--------------- cardnumber = '9670150903536' pin = '90873' set_up browse_to 'http://libcat.scottsdaleaz.gov/patroninfo' wait_for_title "Millennium Web Catalog" # Make sure whole page has loaded over flakey WiFi sleep 4 send cardnumber tab send pin enter #--------------- It's also handy to learn about the Windows message queue and sending commands there. It makes it easier/more reliable to trigger actions using, say, accelerator commands or keyboard shortcuts (e.g. ctrl+v) instead of mouse clicks or menu navigation. I had some code that hooked into Watir and took screenshots of each page, pasted them into Paintbrush, then saved them to disk, but at the moment I have no idea where that code is. But sending raw key messages made it pretty easy to do. http://www.autoitscript.com/autoit3/docs/appendix/WinMsgCodes.htm -- James Britt www.jamesbritt.com - Playing with Better Toys www.ruby-doc.org - Ruby Help & Documentation www.rubystuff.com - The Ruby Store for Ruby Stuff www.neurogami.com - Smart application development