Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Determine if a WebPage is completely loaded in IE


  • Please log in to reply
75 replies to this topic
bennoman
  • Members
  • 11 posts
  • Last active: Jul 17 2007 02:06 PM
  • Joined: 14 Jun 2007
hey I never even saw the zip file available. :O
I bet this will get around having to call over a help desk tech to re-install the newest version :D

Thanks again n-l-i-d for all your help!

Patrick
  • Guests
  • Last active:
  • Joined: --
Hi,
Sorry for my poor knowledge of AHK, but the solution provided here doesn't work with me.
I downloaded "CoHelper.ahk" and I have saved Seans' script in "WebSiteFinished.ahk".
In a testfile "test.ahk" I put this code. But when launching the script (F12), the calculator appears before the web page has completely finished loading.
What am I doing wrong?
Many thanks for your help.
Patrick.
F12::

Run, C:\Program Files\Internet Explorer\iexplore.exe http://maps.google.ca/maps?ie=UTF-8&oe=UTF-8&hl=en&tab=wl&q=,,,Pid
RunWait, WebsiteFinished.ahk
run calc.exe

Return


Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

F12::
Run, C:\Program Files\Internet Explorer\iexplore.exe http://maps.google.ca/maps?ie=UTF-8&oe=UTF-8&hl=en&tab=wl&q=,,,Pid
RunWait, WebsiteFinished.ahk
run calc.exe
Return

The key here is to obtain the window handle of Internet Explorer_Server control, but, if you run new iexplore.exe, this control seems not created until the web page starts loading, so it defeats the purpose of the script in a sense.
I suggest to use the following instead:

#Include CoHelper.ahk
F12::
CoInitialize()
pie := ActiveXObject("InternetExplorer.Application")
Invoke(pie, "Visible=", "True")
Invoke(pie, "Navigate", "http://maps.google.ca/maps?ie=UTF-8&oe=UTF-8&hl=en&tab=wl&q=")
Loop
{
	If	Invoke(pie, "ReadyState") = 4
		Break
	Sleep,	500
}
Release(pie)
CoUninitialize()
Run,	calc.exe
Return


Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006

The key here is to obtain the window handle of Internet Explorer_Server control


ok, (silly question...)


how do we do that ?? [especially if control is inside another 'wrapper' like Maxathon, etc.]

and

Invoke() will then work as usual ???
Joyce Jamce

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

how do we do that ?? [especially if control is inside another 'wrapper' like Maxathon, etc.]

I can't see the problem with it. If it's a control inside any top-level window, you can use it no matter what the top-level window really is, unless the proggy tries to fake it.

I could use it even with Firefox + IETab plugin.
SetTitleMatchMode 2
ControlGet, hIESvr, hWnd,, Internet Explorer_Server1, Firefox ahk_class MozillaUIWindowClass


Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006
likely the complexity of DOM controls generally is fogging over my understanding, but....


is there away to apply to DOM controls to the 'external' control handle we've found ?


ie. invoke "Navigate" upon the object (we did not create) ?




(and speaking of firefox, can it too be an activeX boject, an InternetExplorer.Application equivalence ?)
Joyce Jamce

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

is there away to apply to DOM controls to the 'external' control handle we've found ?

Yes, that's what this script does.

ie. invoke "Navigate" upon the object (we did not create) ?

Navigate is for WebBrowser control, not for DOM. And yes again if the container implements WebBrowser control too, which is likely.
BTW, in this "Navigate" case, you may directly do it via DOM:
Invoke(pdoc, "url=", URL)

(and speaking of firefox, can it too be an activeX boject, an InternetExplorer.Application equivalence ?)

The IETab plugin implements the WebBrowser control, i.e., Shell.Explorer.

Murp-e
  • Members
  • 531 posts
  • Last active: Sep 27 2011 11:44 AM
  • Joined: 12 Jan 2007
This is very helpfull. I always had to resort to waiting for the statusbar text to show Done, but this has several disadvantages. For example, if the mouse cursor is above a link the statusbar text will normally show the URL of the link instead of showing Done. Different languages also display different Done-strings. This method seems much more reliable. I suppose it will work in both IE6 and IE7 -right?

P.S. Sean I implemented your libcurl script to create a very simple software upgrade function for my program. It downloads a text file to get the newest version of the program, if a new version is available it can download the -NSIS- installer. The script creates an on-the-fly VBS script which silently uninstalls the old version, then silently installs the new version. The program is about 1 mb so the whole process is very fast. Might be something worth posting?

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

I suppose it will work in both IE6 and IE7 -right?

Yes.

Sean I implemented your libcurl script

I think you meant olfen's.

It downloads a text file to get the newest version of the program, if a new version is available it can download the -NSIS- installer. The script creates an on-the-fly VBS script which silently uninstalls the old version, then silently installs the new version. The program is about 1 mb so the whole process is very fast. Might be something worth posting?

Sure. It sounds great!

Murp-e
  • Members
  • 531 posts
  • Last active: Sep 27 2011 11:44 AM
  • Joined: 12 Jan 2007
Great.

You're right, I suppose I remember your name because his example implements your filehelper.ahk. Thanks to the both of you then, I'll be sure to update my credits.

Alright, I'll start a new thread in the forum.

Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006

Navigate is for WebBrowser control, not for DOM.



Sean, so simple you make it. Very much helpful, thanks.


btw, is the only way to have the WB create an object upon which to invoke DOM controls is by 'Navigate' ?


The IETab plugin implements the WebBrowser control, i.e., Shell.Explorer.


in the inverse direction, can we pull up an active x 'webrowser' like control for FFox html rendering object ? (vs. MS IE's webbrowser control)
Joyce Jamce

crxvfr
  • Members
  • 89 posts
  • Last active: Aug 24 2011 05:01 PM
  • Joined: 10 Mar 2006

Many times asked so far. You made ppl happy now.

YEAY!!!!

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

btw, is the only way to have the WB create an object upon which to invoke DOM controls is by 'Navigate' ?

I'm not sure if I understood you here. I believe DOM and WB are completely independent objects. So, in strict logical sense, they don't require each other, I suppose.

in the inverse direction, can we pull up an active x 'webrowser' like control for FFox html rendering object ? (vs. MS IE's webbrowser control)

No, firefox doesn't implement any ActiveX control, it uses just its own rendering engine.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
Here is another ways to access DOM of Internet Explorer_Server.
Although it's not extensively tested, worked fine so far here in XPSP2 and IE7.
Please execute it when mouse is on the IE window or alike.

It's done through Accessibility Standard Library.

CoordMode, Mouse
MouseGetPos, xpos, ypos, , hIESvr, 2

IID_IHTMLWindow2	:= "{332C4427-26CB-11D0-B483-00C04FD90119}"
IID_IHTMLElement	:= "{3050F1FF-98B5-11CF-BB82-00AA00BDCE0B}"

ACC_Init()
pacc := ACC_AccessibleObjectFromWindow(hIESvr)
pwin := COM_QueryService(pacc,IID_IHTMLWindow2,IID_IHTMLWindow2)
sResult .= "Window Object: " . pwin . "`tRole: " . acc_Role(pacc) . "`n"
COM_Release(pacc)

pacc :=	0
pacc := ACC_AccessibleObjectFromPoint(xpos, ypos)
plmt := COM_QueryService(pacc,IID_IHTMLElement,IID_IHTMLElement)
sResult .= "Element Object: " . plmt . "`tRole: " . acc_Role(pacc) . "`n"
COM_Release(pacc)

COM_Release(pwin)
COM_Release(plmt)
ACC_Term()

MsgBox,	% sResult


Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006
wow. staining my mind to follow that!

@Sean,

tiny suggestion. in the ACC_ library, important maybe to keep *all* functions tied to the library. ie. HEX() to acc_hex() ... because... otherwise risk conflicting with other hex() function on other libraries or user's own! (example too in the dde wrapper, for example.. also has a hex()... "dde_hex()" if that makes sense.)


huge(?) question. been tearing with my mind on this, but not finding the path... How to turn the document object handle (or any other object, actually) into handle that can be bound COM_events ?

COM_ConnectObject(pobj,"ON_") such thing, if my comprehension isn't too foggy on this...


how to turn events into callbacks ?
Joyce Jamce