[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Attach to running IE instance without watir?

Geoff Cheshire

1/16/2007 6:12:00 AM

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

--
Posted via http://www.ruby-....

8 Answers

Jano Svitok

1/16/2007 7:46:00 PM

0

On 1/16/07, Geoff Cheshire <gtc@cheshirelaw.com> wrote:
> 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.)

bpettichord

1/17/2007 5:42:00 AM

0

Geoff Cheshire wrote:
> 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

David Mullet

1/17/2007 3:21:00 PM

0


Geoff Cheshire wrote:
> 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
>
> --
> Posted via http://www.ruby-....

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

Geoff Cheshire

1/17/2007 3:33:00 PM

0

David Mullet wrote:

> 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

--
Posted via http://www.ruby-....

Geoff Cheshire

1/17/2007 6:28:00 PM

0

David Mullet wrote:

> 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

--
Posted via http://www.ruby-....

David Mullet

1/17/2007 7:23:00 PM

0


Geoff Cheshire wrote:
> David Mullet wrote:
>
> > 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
>
> --
> Posted via http://www.ruby-....

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/refl...

Mully

Geoff Cheshire

1/17/2007 8:35:00 PM

0

David Mullet wrote:
> 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/refl...

That's it! window.LocationUrl was the ticket.

Thanks for your help!

-Geoff

--
Posted via http://www.ruby-....

bpettichord

1/26/2007 5:47:00 AM

0



On Jan 17, 12:27 pm, Geoff Cheshire <g...@cheshirelaw.com> wrote:
> 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