 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
ahklerner
Joined: 26 Jun 2006 Posts: 1381 Location: USA
|
Posted: Mon Dec 10, 2007 2:29 am Post subject: |
|
|
That still does not work for me.
The first loop never breaks. _________________
ʞɔпɟ əɥʇ ʇɐɥʍ |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Mon Dec 10, 2007 3:16 am Post subject: |
|
|
| ahklerner wrote: | That still does not work for me.
The first loop never breaks. |
This is what lexikos said, invoking "ReadyState" on wrong pie. Please run the script I linked how many pages/windows of IE are running after "Navigate". |
|
| Back to top |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1381 Location: USA
|
Posted: Mon Dec 10, 2007 3:29 am Post subject: |
|
|
I get this: | Quote: |
---------------------------
IEJS.AHK
---------------------------
1180506 : "","","","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe"
: "","","","",""
: "","","","",""
: "","","","",""
: "","","","",""
: "","","","",""
: "","","","",""
5047356 : "","","","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe"
591834 : "","","Website found. Waiting for reply...","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe"
---------------------------
OK
---------------------------
|
With this:
| Code: |
^F1::
MsgBox, % "Pie " . LoadIEDone("http://www.google.com")
return
LoadIEDone(URL_TO_LOAD)
{
com_CoInitialize()
pie := com_ActiveXObject("InternetExplorer.Application")
com_Invoke(pie, "Visible=", True)
com_Invoke(pie, "Navigate", URL_TO_LOAD)
psh := COM_CreateObject("Shell.Application")
psw := COM_Invoke(psh, "Windows")
Loop, % COM_Invoke(psw, "Count")
pwb := COM_Invoke(psw, "Item", A_Index-1), sInfo .= COM_Invoke(pwb, "hWnd") . " : """ . COM_Invoke(pwb, "LocationURL") . """,""" . COM_Invoke(pwb, "LocationName") . """,""" . COM_Invoke(pwb, "StatusText") . """,""" . COM_Invoke(pwb, "Name") . """,""" . COM_Invoke(pwb, "FullName") . """`n", COM_Release(pwb)
COM_Release(psw)
COM_Release(psh)
;COM_Term()
MsgBox, % sInfo
Loop
If pdoc:=Com_Invoke(pie, "Document")
Break
Else Sleep 100
Loop
If Com_Invoke(pdoc, "readyState") = "complete"
Break
Else Sleep 500
Com_Release(pdoc)
com_Release(pie)
com_CoUninitialize()
return pie
} |
_________________
ʞɔпɟ əɥʇ ʇɐɥʍ |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Mon Dec 10, 2007 4:53 am Post subject: |
|
|
| ahklerner wrote: | I get this: | Quote: |
---------------------------
IEJS.AHK
---------------------------
1180506 : "","","","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe"
: "","","","",""
: "","","","",""
: "","","","",""
: "","","","",""
: "","","","",""
: "","","","",""
5047356 : "","","","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe"
591834 : "","","Website found. Waiting for reply...","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe"
---------------------------
OK
---------------------------
|
|
So, the linked script seemed to work, at least partially as there exist lots of blank ones too. I was worried it also might not work in Vista.
Which one the web page is actually loading in? Is it the same one as the original pie or not?
| Code: | | MsgBox, % pie . " | hWnd: " . COM_Invoke(pie, "hWnd") |
Anyway, now it may be a matter of picking the corrected one where the wanted web page is loading that I can't do from here. |
|
| Back to top |
|
 |
Erittaf
Joined: 02 Nov 2007 Posts: 188
|
Posted: Mon Dec 10, 2007 10:31 am Post subject: |
|
|
| Quote: | | 591834 : "","","Website found. Waiting for reply...","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe" |
I would think that the window/pie we want is this one. Could we loop through these windows and reliably pick out the wanted window by statusbar text containing something? Would that be a reliable way to go? It's silly how much harder this appears in Vista! |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Mon Dec 10, 2007 12:04 pm Post subject: |
|
|
| Erittaf wrote: | | Quote: | | 591834 : "","","Website found. Waiting for reply...","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe" |
I would think that the window/pie we want is this one. |
Then, you may use this:
| Code: | LoadIEDone(URL_TO_LOAD)
{
COM_Init()
pie := COM_ActiveXObject("InternetExplorer.Application")
COM_Invoke(pie, "Visible=", True)
COM_Invoke(pie, "Navigate", URL_TO_LOAD)
COM_Release(pie)
pie := 0
psh := COM_CreateObject("Shell.Application")
psw := COM_Invoke(psh, "Windows")
Loop, % COM_Invoke(psw, "Count")
{
pwb := COM_Invoke(psw, "Item", A_Index-1)
If COM_Invoke(pwb, "Name") = "Windows Internet Explorer"
&& COM_Invoke(pwb, "StatusText") = "Website found. Waiting for reply..."
{
pie := pwb
Break
}
Else COM_Release(pwb)
}
COM_Release(psw)
COM_Release(psh)
If pie
Loop
If COM_Invoke(pie, "ReadyState") = 4
Break
Else Sleep 500
COM_Release(pie)
COM_Term()
Return pie
}
|
One thing though. The StatusText may be varying, so may be needed some fine-tuning. |
|
| Back to top |
|
 |
Erittaf
Joined: 02 Nov 2007 Posts: 188
|
Posted: Tue Dec 11, 2007 3:15 am Post subject: |
|
|
might there be a way to check for status text containing anything?? from the looks of it the window we want is the only one that has any status text.
Also, For what I need I know what website I am send the browser to. Is there a way to do something like (psuedocode) | Code: | | COM_Invoke(pwb, "addressBar") = "SomeSiteWeAreGoingTo" |
Pooisble?? |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Tue Dec 11, 2007 4:02 am Post subject: |
|
|
| Erittaf wrote: | Also, For what I need I know what website I am send the browser to. Is there a way to do something like (psuedocode) | Code: | | COM_Invoke(pwb, "addressBar") = "SomeSiteWeAreGoingTo" |
|
I don't really know about that, however, I'm a bit skeptical about it. Haven't you tried it? Anyway, there were two observations from the result of ahklerner. One is what you said: only the needed one has a status text. If it's consistently so, you may simply use
| Code: | | COM_Invoke(pwb, "StatusText") |
instead of
| Code: | | COM_Invoke(pwb, "StatusText") = "Website found. Waiting for reply..." |
The other one is: the result appeared somehow chronologically. If it always is, the first loop may not be needed, could simply replace it as
| Code: | | pie := COM_Invoke(psw, "Item", COM_Invoke(psw, "Count") - 1) |
|
|
| Back to top |
|
 |
Erittaf
Joined: 02 Nov 2007 Posts: 188
|
Posted: Tue Dec 11, 2007 5:46 am Post subject: |
|
|
sorry, no I haven't tried it... No vista box
Thanks for the info, will write some tests and try them at work or something. Thanks! |
|
| Back to top |
|
 |
Aamir Guest
|
Posted: Wed Jan 16, 2008 1:16 pm Post subject: Re: Determine if a WebPage is completely loaded in IE |
|
|
Thanks Sean for the code.
I wan to ask whether the code works equally well for AVANT browser
http://www.avantbrowser.com/
This browser uses Internet Explorer's engine. |
|
| Back to top |
|
 |
Erittaf
Joined: 02 Nov 2007 Posts: 188
|
Posted: Wed Feb 13, 2008 7:13 pm Post subject: |
|
|
Well I have a Vista box now and after helping with another related thread Lexikos pointed me at the answer for the vista problem. After playing with it some more it seems that the difference is in how long it takes for vista to load. It never got there in time on my system. However if you modify one of the two lines noted in the code below you can tweak how long it takes before timing out and throwing the error. (I just set the first one to 500 since the loop breaks when the page actually finishes loading... it doesn't take up too much extra on the resources, at least not in vista terms.)
Happy coding!
| Code: | IEReady(hIESvr = 0)
{
If Not hIESvr
{
Loop, 50 ;<-------------modify this line!!
{
ControlGet, hIESvr, hWnd, , Internet Explorer_Server1, A ; ahk_class IEFrame
If hIESvr
Break
Else Sleep 100 ;<-------------or modify this line!!
}
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
}
|
|
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7299 Location: Australia
|
Posted: Thu Feb 14, 2008 12:58 am Post subject: |
|
|
If you change "Loop, 50" to "Loop", it will never time out. It isn't "the vista problem", but "the slow PC problem."  |
|
| Back to top |
|
 |
Erittaf
Joined: 02 Nov 2007 Posts: 188
|
Posted: Thu Feb 14, 2008 1:05 am Post subject: |
|
|
lol, true enough. Maybe I need to increase my Precision-O-Meter  |
|
| Back to top |
|
 |
Mike" Guest
|
Posted: Sat Apr 05, 2008 5:17 am Post subject: |
|
|
Thanks Sean.
This seems really great.
Is it possible to use Invoke() to change size of IE window ? |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7299 Location: Australia
|
Posted: Sat Apr 05, 2008 6:23 am Post subject: |
|
|
| Why not just use WinMove? I suppose you could invoke the Width and Height properties of the WebBrowser/IE object... |
|
| 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
|