Attach to running IE instance without watir?

G

Geoff Cheshire

Hi all,

I've done the Google thing for several days and I'm hitting a blank.
I'm wondering if there's a way to attach to a running IE process (on
Windows) by using win32ole alone. I can do it with watir, ie =
Watir::IE.attach:)url, url), but I may need to do this on platforms that
don't have watir installed.

Thanks in advance for any pointers,
Geoff
 
J

Jan Svitok

Hi all,

I've done the Google thing for several days and I'm hitting a blank.
I'm wondering if there's a way to attach to a running IE process (on
Windows) by using win32ole alone. I can do it with watir, ie =
Watir::IE.attach:)url, url), but I may need to do this on platforms that
don't have watir installed.

Thanks in advance for any pointers,
Geoff

Hi,

it's certainly possible. In programming ruby you'llfind an example how
to attach to running excel. Then you'll need to find out Explorer's
API - it shouldn't be that hard (see MSDN etc.)
 
B

Bret Pettichord

Geoff said:
I've done the Google thing for several days and I'm hitting a blank.
I'm wondering if there's a way to attach to a running IE process (on
Windows) by using win32ole alone. I can do it with watir, ie =
Watir::IE.attach:)url, url), but I may need to do this on platforms that
don't have watir installed.

The Watir code uses win32ole to implement Watir::IE.attach. Have you
looked at it? It's open source and the latest code is in the repository
on OpenQA.org.

Bret
 
M

mully

Geoff said:
Hi all,

I've done the Google thing for several days and I'm hitting a blank.
I'm wondering if there's a way to attach to a running IE process (on
Windows) by using win32ole alone. I can do it with watir, ie =
Watir::IE.attach:)url, url), but I may need to do this on platforms that
don't have watir installed.

Thanks in advance for any pointers,
Geoff

IE objects are included in the Windows collection of the Shell object,
so you could do something like the following (code not tested):

shell = WIN32OLE.new('Shell.Application')
shell.Windows.each do | window |
if window.Document.Title == 'Your Title Here'
ie = window
end
end

Mully
 
G

Geoff Cheshire

David said:
IE objects are included in the Windows collection of the Shell object,
so you could do something like the following (code not tested):

Excellent -- I'll give it a go! Thanks everyone for your help. I've
been wading trough the watir source (oh man, that was a bad pun), but
it's nice to have a small snippet like that to get me started.

Thanks again, and I'll post back if I get it working. (I'm working on a
preview in browser command for the e Text Editor, which uses TextMate
bundles--but Windows doesn't have AppleScript so I'm rewriting those
commands in ruby.)

-Geoff
 
G

Geoff Cheshire

David said:
shell = WIN32OLE.new('Shell.Application')
shell.Windows.each do | window |

Do you how I'd look for the URL instead of window.Document.Title? I'm
guaranteed to have a file name (with full path), but may not know the
title. Or could you point me to the docs where I could find all the
methods and properties? (I found them from IE, but not for
Shell.Application.)

Thanks again!
Geoff
 
M

mully

Geoff said:
Do you how I'd look for the URL instead of window.Document.Title? I'm
guaranteed to have a file name (with full path), but may not know the
title. Or could you point me to the docs where I could find all the
methods and properties? (I found them from IE, but not for
Shell.Application.)

Thanks again!
Geoff

Each item in the the shell's Windows collection is an actual
InternetExplorer object, so once you get to that object you will
utilize the standard IE object's properties and methods:

ie.LocationUrl
ie.LocationName

Here's some IE object docs:

http://msdn.microsoft.com/workshop/browser/webbrowser/reflist_vb.asp

Mully
 
B

Bret Pettichord

Or could you point me to the docs where I could find all the
methods and properties? (I found them from IE, but not for
Shell.Application.)

shell = WIN32OLE.new('Shell.Application')
puts shell.ole_methods
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,042
Latest member
icassiem

Latest Threads

Top