Mike asked:
How do you invoke autoIt from a Watir script ? (I am basically interested in
getting to left & right mouseclicks, I assume you can't do mouse clicks with
send_keys) All the AutoIt documentation is for VB Script.
# I got this to run at least, not sure if its right :
class Autoit
def initialize(libname)
end
end
$autoit=Autoit.new("AutoItX3.Control")
# but I can't get this to work later on in the script
$autoIt.MouseClick "left"
# I must be missing something, or may be making it too complicated.
# It gets : myscript.rb:58: undefined method `MouseClick' for nil:NilClass
(NoMethodError)
Tom's right, $autoit is a different variable from $autoIt, but that will just
get you a different error message - a NoMethodError. You can define the Autoit
class like this:
require 'win32ole'
class AutoIt < WIN32OLE
def initialize
super("AutoItX3.Control")
end
end
$autoit = AutoIt.new
But I would just do:
require 'win32ole'
$autoit = WIN32OLE.new("AutoItX3.Control")
And with either, you should be able to use the methods and properties as you
expect from the doco:
$autoit.mouseclick "left" # or MouseClick or mOuSeClIcK...
Another way is a little more complicated:
require 'win32ole'
module AutoIt
class << self
def instance
unless @instance
@instance = WIN32OLE.new("AutoItX3.Control")
end
@instance
end
def method_missing(*args, &block)
instance.send(*args, &block)
end
end
end
This will automatically create the AutoIt control when it's needed. You don't
need to explicitly create it -- use it like this:
AutoIt.mouseclick "left"
Cheers,
Dave
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general