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
autoit = WIN32OLE.new(“AutoItX3.Control”)
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
A key distinction here is between window.Name and window.Document.Title
[Re-posting my reply, as it seems to have been truncated on Google
Groups…]
A key distinction here is between window.Name and
window.Document.Title.
window.Document.Title is the Title as defined in the HTML code of a
window with a Type of “HTML Document”. This probably equates to the
window.LocationName property. The titlebar text will include both
window.Document.Title and window.Name, so…
if window.Document.Title =~ /Internet Explorer/
will usually NOT work, though…
if window.Name =~ /Internet Explorer/
…would work.
To grab an IE window from the Shell.Application.Windows collection…
You could test the Type property:
if window.Type == ‘HTML Document’
or you could test the window.Name property:
if window.Name =~ /Internet Explorer/
But to grab a particular IE window from the
Shell.Application.Windows
collection, you could use the window.Document.Title or
window.LocationName property
A key distinction here is between window.Name and
window.Document.Title.
window.Document.Title is the Title as defined in the HTML code of a
window with a Type of “HTML Document”. This probably equates to the
window.LocationName property. The titlebar text will include both
window.Document.Title and window.Name, so…
The problem was that I had no html document loaded; the titlebar
text was “about:blank - Microsoft Internet Explorer” but
window.Document.Title was simply “”.
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
A key distinction here is between window.Name and window.Document.Title
.
window.Document.Title is the Title as defined in the HTML code of a
window with a Type of “HTML Document”. This probably equates to the
window.LocationName property. The titlebar text will include both
window.Document.Title and window.Name, so…
if window.Document.Title =~ /Internet Explorer/
will usually NOT work, though…
if window.Name =~ /Internet Explorer/
…would work.
To grab an IE window from the Shell.Application.Windows collection…
You could test the Type property:
if window.Type == ‘HTML Document’
or you could test the window.Name property:
if window.Name =~ /Internet Explorer/
But to grab a particular IE window from the Shell.Application.Windows
collection, you could use the window.Document.Title or
window.LocationName property
if window.Document.Title =~ /Yahoo/
if window.LocationName =~ /Yahoo/
David
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.