Does watir::IE.attach() :hwnd support embedded browsers ?

179 views
Skip to first unread message

basu

unread,
Feb 24, 2009, 12:40:38 AM2/24/09
to Watir General
I want to know whether the attach() method supports access to the
browser embedded in a windows applications (Ex: Internet
Explorer_Server1 control embedded in the winamp player) , if not could
some one provide me the inputs on how to achieve this
Thanks,
Basu

basu

unread,
Mar 2, 2009, 3:13:44 AM3/2/09
to Watir General
i tried getting the automation object of the embedded browser but no
success, i not able to figure out the issue, could some give inputs on
this please ?
(There is an function defined in IE.au3 (autoitv3 UDF) to get the IE
object from the IE handle, i tried re writting the same function in
ruby)

Code tried ..

# Start winamp player
.......

require 'Win32API'
SMTO_ABORTIFHUNG = 0x0002
Win32API.new("ole32", "CoInitialize", ['P'] , 'I').call(0)

reg_msg = Win32API.new("user32", "RegisterWindowMessage", ['P'] ,
'I').call("WM_HTML_GETOBJECT")
puts reg_msg

# "Main Window" is title of winamp player
# "Internet Explorer_Server1" is a IE control embedded in the player
hnd = @@autoit.ControlGetHandle("Main Window", "", "Internet
Explorer_Server1")
puts hnd


result=" "*16

aInt = [0xA7, 0x31, 0x0, 0xA0, 0xC9, 0x8, 0x26, 0x37].pack 'I*'
a = [0x626FC520, 0xA41E, 0x11CF, aInt].pack 'IIIP'


sendMessagetimeout = Win32API.new("user32", "SendMessageTimeout",
['L','I','I','I','I','I','P'] , 'L')
sendMessagetimeout.call(hnd.hex, reg_msg, 0, 0, SMTO_ABORTIFHUNG,
1000, result)
puts result.unpack("L")

idisp=0
oIE = Win32API.new("oleacc", "ObjectFromLresult", ['P', 'P','I','P'] ,
'L')
oIE.call(result, a, 0, idisp)

# returning zero
puts idisp.unpack("L")

Thanks in advance !

mwolfe

unread,
Apr 29, 2009, 3:28:40 PM4/29/09
to Watir General
hey basu, did you ever figure out this issue?
I'm trying to do essentially the same thing (work with an embedded IE
control).
I found the function __IEControlGetObjFromHWND
from the IE.au3
Of course, this is not built into the binary for autoit so I can't use
that. It looks (kind of) like you tried to implement that in ruby.
Unfortunately its pretty complicated for a OLE/COM newbie like me. It
seems like there should be an easier way though but I have yet to
come up with anything.
Let me know if you've figured it out.

mwolfe

unread,
Apr 30, 2009, 12:03:16 PM4/30/09
to Watir General
I have been working more on the issue and have discussed it on my blog
here:
http://www.wolfewebservices.com/blog/attaching-watir-embedded-ie-browser
I Haven't yet come up with a solution yet but just thought i'd share
my current
knowledge of the problem.

mwolfe

unread,
May 6, 2009, 12:07:31 PM5/6/09
to Watir General
someone posted a solution to this problem on the rubyforge forums,
here is the link:
http://rubyforge.org/forum/forum.php?thread_id=33188&forum_id=319
I haven't tested it yet but I would imagine it works. It looks pretty
complicated though. Hopefully it will get put into the core watir code
eventually.

Bret Pettichord

unread,
May 6, 2009, 3:01:09 PM5/6/09
to watir-...@googlegroups.com
This is a useful collection of links on this issue.

Could you open up a Jira ticket and include these links in it?

Bret
--
Bret Pettichord
CTO, WatirCraft LLC, www.watircraft.com
Lead Developer, Watir, www.watir.com
Blog, www.io.com/~wazmo/blog
Twitter, www.twitter.com/bpettichord

Ask me about Watir training
www.watircraft.com/training

Reply all
Reply to author
Forward
0 new messages