On Apr 12, 10:36 am, David Mullet <david.mul... / gmail.com> wrote:
> sean_n wrote:
> > Here's an example of using autoit inside of ruby.
>
> > require 'win32ole'
> > autoit = WIN32OLE.new("AutoItX3.Control")
> > autoit.WinActivate('Yahoo!')
>
> > So if this works, how come this doesn't work?
>
> > require 'win32ole'
> > autoit = WIN32OLE.new("AutoItX3.Control")
> > obj=autoit.ObjGet('','InternetExplorer.Application')
>
> > How do I call the ObjGet() function?  In other words, what COM object
> > contains that method?
>
> I can't offer much help with regard to AutoIt, but you can connect to an
> existing instance of IE using win32ole and the Shell object's Windows
> collection:
>
> ie = nil
> for window in WIN32OLE.new('Shell.Application').Windows
>   begin
>     if window.Document.Title =~ /Yahoo/
>     ie = window
>   end
>   rescue
>   end
> end

This seems not to work.

require 'win32ole'
ie = nil
WIN32OLE.new('Shell.Application').Windows.each do |window|
  p window.FullName
  p window.Name
  begin
    title = window.Document.Title
    p title
    if title =~ /Internet Explorer/
      ie = window
    end
  rescue
  end
end
p ie

--- output ---
"C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE"
"Microsoft Internet Explorer"
""
nil