 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Sean
Joined: 12 Feb 2007 Posts: 1255
|
Posted: Wed May 16, 2007 1:06 pm Post subject: Determine if a WebPage is completely loaded in IE |
|
|
It'll check whether a webpage is completely loaded or not in the active Internet Explorer.
NEED the latest COM Standard Library.
| Code: | ; Run, iexplore.exe http://www.google.com/
MsgBox, % IEReady()
Return
IEReady(hIESvr = 0)
{
If Not hIESvr
{
Loop, 50
{
ControlGet, hIESvr, hWnd, , Internet Explorer_Server1, A ; ahk_class IEFrame
If hIESvr
Break
Else Sleep 100
}
If Not hIESvr
Return """Internet Explorer_Server"" Not Found."
}
Else
{
WinGetClass, sClass, ahk_id %hIESvr%
If Not sClass == "Internet Explorer_Server"
Return "The specified control is not ""Internet Explorer_Server""."
}
COM_Init()
If DllCall("SendMessageTimeout", "Uint", hIESvr, "Uint", DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT"), "Uint", 0, "Uint", 0, "Uint", 2, "Uint", 1000, "UintP", lResult)
&& DllCall("oleacc\ObjectFromLresult", "Uint", lResult, "Uint", COM_GUID4String(IID_IHTMLDocument2,"{332C4425-26CB-11D0-B483-00C04FD90119}"), "int", 0, "UintP", pdoc)=0
&& pdoc && pweb:=COM_QueryService(pdoc,IID_IWebBrowserApp:="{0002DF05-0000-0000-C000-000000000046}")
Loop
If COM_Invoke(pweb, "ReadyState") = 4
Break
Else Sleep 500
COM_Release(pdoc)
COM_Release(pweb)
COM_Term()
Return pweb ? "DONE!" : False
}
|
Last edited by Sean on Tue Jan 15, 2008 11:00 am; edited 2 times in total |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3600 Location: Belgrade
|
Posted: Wed May 16, 2007 1:12 pm Post subject: |
|
|
Many times asked so far. You made ppl happy now. _________________
 |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5594
|
Posted: Wed May 16, 2007 1:37 pm Post subject: |
|
|
Thanks Sean. I need this for a couple of scripts.
 |
|
| Back to top |
|
 |
boge
Joined: 16 May 2007 Posts: 11
|
Posted: Wed May 16, 2007 3:26 pm Post subject: |
|
|
very nice sean...
btw, do you have something similar for firefox?
since I work most of the time with firefox... |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10465
|
Posted: Wed May 16, 2007 6:22 pm Post subject: |
|
|
| Great work. I've added it to the FAQ: |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1255
|
Posted: Thu May 17, 2007 2:12 pm Post subject: |
|
|
| Chris wrote: | | Great work. I've added it to the FAQ |
Thanks! |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1255
|
Posted: Thu May 17, 2007 2:14 pm Post subject: |
|
|
| boge wrote: | btw, do you have something similar for firefox?
since I work most of the time with firefox... |
Unfortunately, no. I don't know of a way with firefox. |
|
| Back to top |
|
 |
bennoman Guest
|
Posted: Thu Jun 14, 2007 5:02 pm Post subject: This isnt working for me |
|
|
Im relativley new to ahk, so maybe im doing something wrong. I copied your code and created a new ahk file on my desktop. Then copied the CoHelper code and saved it as CoHelper.ahk also on my desktop. I then double click on the first file to run it and I get this error:
Error at line 64 in #include file "C:\Documents and Settings\bdmock\Desktop\CoHelper.ahk".
Line Text: :
Error: The leftmost character above is illegal in an expression.
The program will exit.
I have been charged with automating the test order process on one of my companies websites. I have started working on this already and found that the only way to have my script wait for the page to load is to use ImageSearch. This process works so far but this sounds like it will work more efficiently.
What am I doing wrong? How will this work within another script?
Thank you in advance. |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Thu Jun 14, 2007 6:50 pm Post subject: |
|
|
| Just a guess: Wordwrap error while copying? |
|
| Back to top |
|
 |
bennoman
Joined: 14 Jun 2007 Posts: 11
|
Posted: Thu Jun 14, 2007 7:03 pm Post subject: |
|
|
I recopied the code for both programs and still got the same error. I tried copying the code into notepad, textpad, and word all with the same result.
Am I using it properly? Do I need to assign a hotkey to it or call it from another script? It sounds like it is supposed to throw a MsgBox when the page under the mouse is finished loading, when I start the script my mouse is on the desktop. Could this be the problem? If so, how do I start the script while the page is loading? |
|
| Back to top |
|
 |
bennoman
Joined: 14 Jun 2007 Posts: 11
|
Posted: Thu Jun 14, 2007 7:05 pm Post subject: |
|
|
by the way, line 64 is:
Unicode2Ansi(ByRef wString, ByRef sString, nLen = 0)
{
pString := wString + 0 > 65535 ? wString : &wString
If !nLen
nLen := DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int", 0, "Uint", 0, "Uint", 0)
VarSetCapacity(sString, nLen)
DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nLen, "Uint", 0, "Uint", 0)
} |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Thu Jun 14, 2007 7:58 pm Post subject: |
|
|
| Next guess: Try updating your AutoHotkey to the latest version... |
|
| Back to top |
|
 |
bennoman
Joined: 14 Jun 2007 Posts: 11
|
Posted: Thu Jun 14, 2007 8:31 pm Post subject: WOOT |
|
|
That worked! I was still using the version I downloaded last year around september because I do not have admin rights on my computer so I had to call a helpdesk tech over to install the newer version.
Thank you for your help. Next time I have problems like this I will make sure Im using the current version before wasting everyones time in the forum.
Thanks again. |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Thu Jun 14, 2007 8:45 pm Post subject: |
|
|
No prob. You can download the zipped version of AutoHotkey too, for your portable-AutoHotkey-pleasure  |
|
| Back to top |
|
 |
bennoman
Joined: 14 Jun 2007 Posts: 11
|
Posted: Thu Jun 14, 2007 9:29 pm Post subject: |
|
|
Thanks Sean, this works beautifully in my scripts.
Great Job! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|