 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
SammE Guest
|
Posted: Mon Oct 12, 2009 1:36 pm Post subject: Re: Determine if a WebPage is completely loaded in IE |
|
|
| ghee22 wrote: | | SammE wrote: | | Sean wrote: | It'll navigate and wait until a webpage is completely loaded in an Internet Explorer.
NEED the latest COM Standard Library.
| Code: | #Persistent
sUrl := "http://www.autohotkey.com/forum/"
COM_Init()
pweb := COM_CreateObject("InternetExplorer.Application")
sink := COM_ConnectObject(pweb, "IE_")
COM_Invoke(pweb, "Visible", True)
bComplete := False
COM_Invoke(pweb, "Navigate2", sUrl)
While !bComplete
Sleep, 500
COM_DisconnectObject(sink)
COM_Release(pweb)
COM_Term()
Return
OnComplete:
bComplete := True
Return
IE_DocumentComplete(prms, sink)
{
If NumGet(NumGet(prms+0)+24) = NumGet(sink+12)
SetTimer, OnComplete, -10
/* more rigorous way
COM_Release(punk1:=COM_QueryInterface(NumGet(NumGet(prms+0)+24),0))
COM_Release(punk2:=COM_QueryInterface(NumGet(sink+12),0))
If (punk1 = punk2)
SetTimer, OnComplete, -10
*/
}
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}")
{
While, COM_Invoke(pweb, "ReadyState") <> 4
Sleep, 500
While, COM_Invoke(pweb, "document.readyState") <> "complete"
Sleep, 500
COM_Release(pweb)
}
COM_Release(pdoc)
COM_Term()
Return pweb ? "DONE!" : False
}
|
|
hello....
above is Seans code.....
below is my code....
i use @ work....
can someone tell me how to include SEANs code..
| Code: | WinWait, Newtop Inc. - Windows Internet Explorer,
IfWinNotActive, Newtop Inc. - Windows Internet Explorer, , WinActivate, Newtop Inc. - Windows Internet Explorer,
WinWaitActive, Newtop Inc. - Windows Internet Explorer, (( also note that at the time the script is running i have 3 windows with the same name ))
#0::
Sleep, 100
Send, {CTRLDOWN}f{CTRLUP}
WinWait, Find,
IfWinNotActive, Find, , WinActivate, Find,
WinWaitActive, Find,
Send, copyright{ENTER}
sleep, 300
send, {ESC}
sleep, 1000
Send, {SHIFTDOWN}{TAB}
sleep, 300
send, {SHIFTDOWN}{TAB}
sleep, 300
send, {SPACE}
Sleep, 6800 <-- this is where i have the problem some windows could
take about 7 seconds to load others 10 or others
3 seconds... i need the code above to maybe
automatically know when the window finished loading
then continue on with the macro
MouseClick, left, 938, 93
MouseClick, left, 938, 93 ((this is the 3rd window with the same name))
Sleep, 1000
Send, {CTRLDOWN}c{CTRLUP} (( it copies a number from this window ))
sleep, 200
send, {ALTDOWN}{F4}{ALTUP} (( close the third window ))
Sleep, 3400
Send, {ALTDOWN}{F4}{ALTUP} (( close the second window ))
Sleep, 2400
WinWait, Newtop Inc. - Windows Internet Explorer,
IfWinNotActive, Newtop Inc. - Windows Internet Explorer, , WinActivate, Newtop Inc. - Windows Internet Explorer,
WinWaitActive, Newtop Inc. - Windows Internet Explorer,
#5::
MouseClick, left, 1256, 635
Send, c{TAB}{TAB}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}
Sleep, 2000
MouseClick, left, 1255, 635
Sleep, 200
Send, p{TAB}{TAB}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}
sleep, 200
MouseClick, left, 93, 206
Sleep, 200
#6::
MouseClick, left, 427, 1044
Sleep, 1000
WinWait, OrderTracking - Windows Internet Explorer,
IfWinNotActive, OrderTracking - Windows Internet Explorer, , WinActivate, OrderTracking - Windows Internet Explorer,
WinWaitActive, OrderTracking - Windows Internet Explorer,
Sleep, 1500
MouseClick, left, 1117, 744
Sleep, 1000
Send, {PGDN}{PGDN}{PGDN}{PGDN}
sleep, 800
send, {SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{SPACE}
sleep, 1500
send, {CTRLDOWN}v{CTRLUP}{LEFT}{LEFT}{left}{left}{left}{LEFT}{LEFT}{LEFT}{LEFT}{BACKSPACE}{BACKSPACE}{BACKSPACE}
sleep, 1500
send, {TAB}sa{TAB}{TAB}{SPACE}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{SPACE}
sleep, 100
return |
thank you very very much for looking into it
and modyfing my code so it does
what i want it to do... |
I removed everything except IE_Ready() and added a function, Wait_for_IE(). Here's my version of Sean's modified code:
| Code: | Wait_for_IE(IE_title) {
SetTitleMatchMode, 2
WinWaitActive,%IE_title%
IEReady()
SetTitleMatchMode, RegEx
}
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}")
{
While, COM_Invoke(pweb, "ReadyState") <> 4
Sleep, 500
While, COM_Invoke(pweb, "document.readyState") <> "complete"
Sleep, 500
COM_Release(pweb)
}
COM_Release(pdoc)
COM_Term()
Return pweb ? "DONE!" : False
} |
To wait for a certain window to load, I call the function I added like so:
| Code: | | Wait_for_IE("Title of IE window to wait for") |
Hence, with my modified version, I would replace your code:
| Code: | WinWait, OrderTracking - Windows Internet Explorer,
IfWinNotActive, OrderTracking - Windows Internet Explorer, , WinActivate, OrderTracking - Windows Internet Explorer,
WinWaitActive, OrderTracking - Windows Internet Explorer, |
with this code:
| Code: | | Wait_for_IE(" OrderTracking - Windows Internet Explorer") |
|
i tried various combinations
but i have no idea
on how to implement your code
inside my code...
do i save your code individually ?
or instead of my
sleep 7100
do i copy all of that BIG BIG code
i tried.. both actually
but i get errors while trying to run it
please assist..
thanks |
|
| Back to top |
|
 |
ghee22
Joined: 04 Jul 2009 Posts: 36
|
Posted: Mon Oct 12, 2009 1:43 pm Post subject: Re: Determine if a WebPage is completely loaded in IE |
|
|
| SammE wrote: | | ghee22 wrote: | | SammE wrote: | | Sean wrote: | It'll navigate and wait until a webpage is completely loaded in an Internet Explorer.
NEED the latest COM Standard Library.
| Code: | #Persistent
sUrl := "http://www.autohotkey.com/forum/"
COM_Init()
pweb := COM_CreateObject("InternetExplorer.Application")
sink := COM_ConnectObject(pweb, "IE_")
COM_Invoke(pweb, "Visible", True)
bComplete := False
COM_Invoke(pweb, "Navigate2", sUrl)
While !bComplete
Sleep, 500
COM_DisconnectObject(sink)
COM_Release(pweb)
COM_Term()
Return
OnComplete:
bComplete := True
Return
IE_DocumentComplete(prms, sink)
{
If NumGet(NumGet(prms+0)+24) = NumGet(sink+12)
SetTimer, OnComplete, -10
/* more rigorous way
COM_Release(punk1:=COM_QueryInterface(NumGet(NumGet(prms+0)+24),0))
COM_Release(punk2:=COM_QueryInterface(NumGet(sink+12),0))
If (punk1 = punk2)
SetTimer, OnComplete, -10
*/
}
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}")
{
While, COM_Invoke(pweb, "ReadyState") <> 4
Sleep, 500
While, COM_Invoke(pweb, "document.readyState") <> "complete"
Sleep, 500
COM_Release(pweb)
}
COM_Release(pdoc)
COM_Term()
Return pweb ? "DONE!" : False
}
|
|
hello....
above is Seans code.....
below is my code....
i use @ work....
can someone tell me how to include SEANs code..
| Code: | WinWait, Newtop Inc. - Windows Internet Explorer,
IfWinNotActive, Newtop Inc. - Windows Internet Explorer, , WinActivate, Newtop Inc. - Windows Internet Explorer,
WinWaitActive, Newtop Inc. - Windows Internet Explorer, (( also note that at the time the script is running i have 3 windows with the same name ))
#0::
Sleep, 100
Send, {CTRLDOWN}f{CTRLUP}
WinWait, Find,
IfWinNotActive, Find, , WinActivate, Find,
WinWaitActive, Find,
Send, copyright{ENTER}
sleep, 300
send, {ESC}
sleep, 1000
Send, {SHIFTDOWN}{TAB}
sleep, 300
send, {SHIFTDOWN}{TAB}
sleep, 300
send, {SPACE}
Sleep, 6800 <-- this is where i have the problem some windows could
take about 7 seconds to load others 10 or others
3 seconds... i need the code above to maybe
automatically know when the window finished loading
then continue on with the macro
MouseClick, left, 938, 93
MouseClick, left, 938, 93 ((this is the 3rd window with the same name))
Sleep, 1000
Send, {CTRLDOWN}c{CTRLUP} (( it copies a number from this window ))
sleep, 200
send, {ALTDOWN}{F4}{ALTUP} (( close the third window ))
Sleep, 3400
Send, {ALTDOWN}{F4}{ALTUP} (( close the second window ))
Sleep, 2400
WinWait, Newtop Inc. - Windows Internet Explorer,
IfWinNotActive, Newtop Inc. - Windows Internet Explorer, , WinActivate, Newtop Inc. - Windows Internet Explorer,
WinWaitActive, Newtop Inc. - Windows Internet Explorer,
#5::
MouseClick, left, 1256, 635
Send, c{TAB}{TAB}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}
Sleep, 2000
MouseClick, left, 1255, 635
Sleep, 200
Send, p{TAB}{TAB}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}
sleep, 200
MouseClick, left, 93, 206
Sleep, 200
#6::
MouseClick, left, 427, 1044
Sleep, 1000
WinWait, OrderTracking - Windows Internet Explorer,
IfWinNotActive, OrderTracking - Windows Internet Explorer, , WinActivate, OrderTracking - Windows Internet Explorer,
WinWaitActive, OrderTracking - Windows Internet Explorer,
Sleep, 1500
MouseClick, left, 1117, 744
Sleep, 1000
Send, {PGDN}{PGDN}{PGDN}{PGDN}
sleep, 800
send, {SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{SPACE}
sleep, 1500
send, {CTRLDOWN}v{CTRLUP}{LEFT}{LEFT}{left}{left}{left}{LEFT}{LEFT}{LEFT}{LEFT}{BACKSPACE}{BACKSPACE}{BACKSPACE}
sleep, 1500
send, {TAB}sa{TAB}{TAB}{SPACE}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{SPACE}
sleep, 100
return |
thank you very very much for looking into it
and modyfing my code so it does
what i want it to do... |
I removed everything except IE_Ready() and added a function, Wait_for_IE(). Here's my version of Sean's modified code:
| Code: | Wait_for_IE(IE_title) {
SetTitleMatchMode, 2
WinWaitActive,%IE_title%
IEReady()
SetTitleMatchMode, RegEx
}
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}")
{
While, COM_Invoke(pweb, "ReadyState") <> 4
Sleep, 500
While, COM_Invoke(pweb, "document.readyState") <> "complete"
Sleep, 500
COM_Release(pweb)
}
COM_Release(pdoc)
COM_Term()
Return pweb ? "DONE!" : False
} |
To wait for a certain window to load, I call the function I added like so:
| Code: | | Wait_for_IE("Title of IE window to wait for") |
Hence, with my modified version, I would replace your code:
| Code: | WinWait, OrderTracking - Windows Internet Explorer,
IfWinNotActive, OrderTracking - Windows Internet Explorer, , WinActivate, OrderTracking - Windows Internet Explorer,
WinWaitActive, OrderTracking - Windows Internet Explorer, |
with this code:
| Code: | | Wait_for_IE(" OrderTracking - Windows Internet Explorer") |
|
i tried various combinations
but i have no idea
on how to implement your code
inside my code...
do i save your code individually ?
or instead of my
sleep 7100
do i copy all of that BIG BIG code
i tried.. both actually
but i get errors while trying to run it
please assist..
thanks |
Take the code I modified, save it as IE_ready.ahk in the same directory as your code.
At the bottom of your code, write
| Code: | | #include IE_ready.ahk |
|
|
| Back to top |
|
 |
SammE Guest
|
Posted: Mon Oct 12, 2009 2:52 pm Post subject: Re: Determine if a WebPage is completely loaded in IE |
|
|
| ghee22 wrote: | | SammE wrote: | | ghee22 wrote: | | SammE wrote: | | Sean wrote: | It'll navigate and wait until a webpage is completely loaded in an Internet Explorer.
NEED the latest COM Standard Library.
| Code: | #Persistent
sUrl := "http://www.autohotkey.com/forum/"
COM_Init()
pweb := COM_CreateObject("InternetExplorer.Application")
sink := COM_ConnectObject(pweb, "IE_")
COM_Invoke(pweb, "Visible", True)
bComplete := False
COM_Invoke(pweb, "Navigate2", sUrl)
While !bComplete
Sleep, 500
COM_DisconnectObject(sink)
COM_Release(pweb)
COM_Term()
Return
OnComplete:
bComplete := True
Return
IE_DocumentComplete(prms, sink)
{
If NumGet(NumGet(prms+0)+24) = NumGet(sink+12)
SetTimer, OnComplete, -10
/* more rigorous way
COM_Release(punk1:=COM_QueryInterface(NumGet(NumGet(prms+0)+24),0))
COM_Release(punk2:=COM_QueryInterface(NumGet(sink+12),0))
If (punk1 = punk2)
SetTimer, OnComplete, -10
*/
}
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}")
{
While, COM_Invoke(pweb, "ReadyState") <> 4
Sleep, 500
While, COM_Invoke(pweb, "document.readyState") <> "complete"
Sleep, 500
COM_Release(pweb)
}
COM_Release(pdoc)
COM_Term()
Return pweb ? "DONE!" : False
}
|
|
hello....
above is Seans code.....
below is my code....
i use @ work....
can someone tell me how to include SEANs code..
| Code: | WinWait, Newtop Inc. - Windows Internet Explorer,
IfWinNotActive, Newtop Inc. - Windows Internet Explorer, , WinActivate, Newtop Inc. - Windows Internet Explorer,
WinWaitActive, Newtop Inc. - Windows Internet Explorer, (( also note that at the time the script is running i have 3 windows with the same name ))
#0::
Sleep, 100
Send, {CTRLDOWN}f{CTRLUP}
WinWait, Find,
IfWinNotActive, Find, , WinActivate, Find,
WinWaitActive, Find,
Send, copyright{ENTER}
sleep, 300
send, {ESC}
sleep, 1000
Send, {SHIFTDOWN}{TAB}
sleep, 300
send, {SHIFTDOWN}{TAB}
sleep, 300
send, {SPACE}
Sleep, 6800 <-- this is where i have the problem some windows could
take about 7 seconds to load others 10 or others
3 seconds... i need the code above to maybe
automatically know when the window finished loading
then continue on with the macro
MouseClick, left, 938, 93
MouseClick, left, 938, 93 ((this is the 3rd window with the same name))
Sleep, 1000
Send, {CTRLDOWN}c{CTRLUP} (( it copies a number from this window ))
sleep, 200
send, {ALTDOWN}{F4}{ALTUP} (( close the third window ))
Sleep, 3400
Send, {ALTDOWN}{F4}{ALTUP} (( close the second window ))
Sleep, 2400
WinWait, Newtop Inc. - Windows Internet Explorer,
IfWinNotActive, Newtop Inc. - Windows Internet Explorer, , WinActivate, Newtop Inc. - Windows Internet Explorer,
WinWaitActive, Newtop Inc. - Windows Internet Explorer,
#5::
MouseClick, left, 1256, 635
Send, c{TAB}{TAB}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}
Sleep, 2000
MouseClick, left, 1255, 635
Sleep, 200
Send, p{TAB}{TAB}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}
sleep, 200
MouseClick, left, 93, 206
Sleep, 200
#6::
MouseClick, left, 427, 1044
Sleep, 1000
WinWait, OrderTracking - Windows Internet Explorer,
IfWinNotActive, OrderTracking - Windows Internet Explorer, , WinActivate, OrderTracking - Windows Internet Explorer,
WinWaitActive, OrderTracking - Windows Internet Explorer,
Sleep, 1500
MouseClick, left, 1117, 744
Sleep, 1000
Send, {PGDN}{PGDN}{PGDN}{PGDN}
sleep, 800
send, {SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{SPACE}
sleep, 1500
send, {CTRLDOWN}v{CTRLUP}{LEFT}{LEFT}{left}{left}{left}{LEFT}{LEFT}{LEFT}{LEFT}{BACKSPACE}{BACKSPACE}{BACKSPACE}
sleep, 1500
send, {TAB}sa{TAB}{TAB}{SPACE}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{SPACE}
sleep, 100
return |
thank you very very much for looking into it
and modyfing my code so it does
what i want it to do... |
I removed everything except IE_Ready() and added a function, Wait_for_IE(). Here's my version of Sean's modified code:
| Code: | Wait_for_IE(IE_title) {
SetTitleMatchMode, 2
WinWaitActive,%IE_title%
IEReady()
SetTitleMatchMode, RegEx
}
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}")
{
While, COM_Invoke(pweb, "ReadyState") <> 4
Sleep, 500
While, COM_Invoke(pweb, "document.readyState") <> "complete"
Sleep, 500
COM_Release(pweb)
}
COM_Release(pdoc)
COM_Term()
Return pweb ? "DONE!" : False
} |
To wait for a certain window to load, I call the function I added like so:
| Code: | | Wait_for_IE("Title of IE window to wait for") |
Hence, with my modified version, I would replace your code:
| Code: | WinWait, OrderTracking - Windows Internet Explorer,
IfWinNotActive, OrderTracking - Windows Internet Explorer, , WinActivate, OrderTracking - Windows Internet Explorer,
WinWaitActive, OrderTracking - Windows Internet Explorer, |
with this code:
| Code: | | Wait_for_IE(" OrderTracking - Windows Internet Explorer") |
|
i tried various combinations
but i have no idea
on how to implement your code
inside my code...
do i save your code individually ?
or instead of my
sleep 7100
do i copy all of that BIG BIG code
i tried.. both actually
but i get errors while trying to run it
please assist..
thanks |
Take the code I modified, save it as IE_ready.ahk in the same directory as your code.
At the bottom of your code, write
| Code: | | #include IE_ready.ahk |
|
I did....
i saved your code it under the same folder....
after i save it ??
do i try to run it ??
---- i did and it says
error at line 35
line text: while, COM_invoke(pweb, "readyState") <> 4
error: this line does not contain a recognized action
the program will exit
it happen if i try to run your
code
or mine (( once i've included at the bottom of my code --- IE_ready.ahk --- ))) |
|
| Back to top |
|
 |
ghee22
Joined: 04 Jul 2009 Posts: 36
|
Posted: Mon Oct 12, 2009 2:57 pm Post subject: |
|
|
| PM me your code, this is increasingly becoming the inappropriate forum for your issue. |
|
| Back to top |
|
 |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
Posted: Fri Oct 16, 2009 3:49 pm Post subject: |
|
|
Here is script by "Sean" to monitor web page loaded.
Note, you need to download & install the COM Library too.
http://www.autohotkey.com/forum/topic19256.html.
| Code: |
#Persistent
sUrl := "http://www.autohotkey.com/forum/"
COM_Init()
pweb := COM_CreateObject("InternetExplorer.Application")
sink := COM_ConnectObject(pweb, "IE_")
COM_Invoke(pweb, "Visible", True)
bComplete := False
COM_Invoke(pweb, "Navigate2", sUrl)
While !bComplete
Sleep, 500
COM_DisconnectObject(sink)
COM_Release(pweb)
COM_Term()
Return
OnComplete:
bComplete := True
Return
IE_DocumentComplete(prms, sink)
{
If NumGet(NumGet(prms+0)+24) = NumGet(sink+12)
SetTimer, OnComplete, -10
/* more rigorous way
COM_Release(punk1:=COM_QueryInterface(NumGet(NumGet(prms+0)+24),0))
COM_Release(punk2:=COM_QueryInterface(NumGet(sink+12),0))
If (punk1 = punk2)
SetTimer, OnComplete, -10
*/
}
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}")
{
While, COM_Invoke(pweb, "ReadyState") <> 4
Sleep, 500
While, COM_Invoke(pweb, "document.readyState") <> "complete"
Sleep, 500
COM_Release(pweb)
}
COM_Release(pdoc)
COM_Term()
Return pweb ? "DONE!" : False
}
|
Good Luck,  _________________
"Man's quest for knowledge is an expanding series whose limit is infinity" |
|
| Back to top |
|
 |
maxgohan
Joined: 09 Oct 2009 Posts: 81
|
Posted: Sat Oct 17, 2009 8:06 am Post subject: |
|
|
wow i really need this!
thanks, bookmarked! |
|
| Back to top |
|
 |
Tyrsius
Joined: 09 Jul 2009 Posts: 140
|
Posted: Tue Mar 30, 2010 9:49 pm Post subject: |
|
|
I've been working with COM and this function for a while, but I am definitely still learning.
I am working on automating multiple IE windows and wanted to use the pointer (pwb in most examples, I may be using the wrong term) as the identifying parameter instead of the hwnd in the IEReady() function, since I already know the pointer and getting the hwnd is an extra step. It also makes it easier for my to make sure IEReady is checking the right window. I made a very crude edit to the function to do this, but I was hoping to get some feedback to see if I totally butchered it, or if I am on the right track with this.
| Code: |
IEReady(hIEpointer = 0, hIESvr = 0) ; by Sean
{
if hIEpointer ;this was my edit
{
While, COM_Invoke(hIEpointer, "ReadyState") <> 4
Sleep, 500
While, COM_Invoke(hIEpointer, "document.readyState") <> "complete"
Sleep, 500
return
} ;end of my edit
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}")
{
While, COM_Invoke(pweb, "ReadyState") <> 4
Sleep, 500
While, COM_Invoke(pweb, "document.readyState") <> "complete"
Sleep, 500
COM_Release(pweb)
}
COM_Release(pdoc)
;COM_Term()
Return pweb ? "DONE!" : False
}
|
|
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Tue Mar 30, 2010 10:22 pm Post subject: |
|
|
I don't know that co-opting IEReady() is going to help much since your function and his are doing two different things; it would be better to keep the two methods separate, IMO. What you're using is what's basically used in tank's iWeb_Complete() function from his iWeb library. Here's a mod of that function I wrote while re-writing some of his functions for compatability with AHK_L. Instead testing only one aspect and then another it tests both "at the same time":
| Code: | complete(pwb) {
If !pwb
return False
Loop 100 ; will time out after 30 seconds
If (COM_Invoke(pwb,"readyState") = 4)
&& (COM_Invoke(pwb,"document.readystate") = "complete")
Return True
Else Sleep, 300
Return False
} |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
Tyrsius
Joined: 09 Jul 2009 Posts: 140
|
Posted: Tue Mar 30, 2010 10:29 pm Post subject: |
|
|
| sinkfaze wrote: | | I don't know that co-opting IEReady() is going to help much since your function and his are doing two different things; it would be better to keep the two methods separate, IMO. |
I'm confused then, what is his function doing? |
|
| Back to top |
|
 |
steadycookie
Joined: 27 Mar 2009 Posts: 24
|
Posted: Thu Jun 10, 2010 3:25 pm Post subject: Could I do not use SetTimer? |
|
|
Thanks for sharing these codes!
I am new to COM invoke etc. I have some questions about your codes.
1) I do not understand why you use SetTimer. Could I just use a global variable, e.g. bComplete, and set it to true in IE_DocumentComplete?
2) Could you please explain who invokes IE_DocumentComplete()? I searched your COM lib, do not find it.
3) IE_DocumentComplete should be always invoked when loading is completed. So why have to test "NumGet(NumGet(prms+0)+24) = NumGet(sink+12)"?
4) Why the method to test "readyState" is not reliable?
5) I use the following codes. It seems to work. Is there any problem with it?
| Code: |
#Persistent
sUrl := "http://www.autohotkey.com"
COM_Init()
pweb := COM_CreateObject("InternetExplorer.Application")
sink := COM_ConnectObject(pweb, "IE_")
COM_Invoke(pweb, "Visible", True)
bComplete := False
COM_Invoke(pweb, "Navigate2", sUrl)
While !bComplete
Sleep, 500
msgbox load complete!
COM_DisconnectObject(sink)
COM_Release(pweb)
COM_Term()
Return
IE_DocumentComplete(prms, sink)
{
global bComplete
If NumGet(NumGet(prms+0)+24) = NumGet(sink+12){
;SetTimer, OnComplete, -10
bComplete := True
msgbox Done!
}
}
|
Thanks a lot!
| Sean wrote: | I rewrote the script using DocumentComplete event. I suggest to test it against sites the original script used to report falsely.
| Code: | #Persistent
sUrl := "http://www.autohotkey.com/forum/"
COM_Init()
pweb := COM_CreateObject("InternetExplorer.Application")
sink := COM_ConnectObject(pweb, "IE_")
COM_Invoke(pweb, "Visible", True)
COM_Invoke(pweb, "Navigate2", sUrl)
Return
OnComplete:
MsgBox, DONE
COM_DisconnectObject(sink)
COM_Release(pweb)
COM_Term()
ExitApp
IE_DocumentComplete(prms, sink)
{
If NumGet(NumGet(prms+0)+24) = NumGet(sink+12)
SetTimer, OnComplete, -10
/* more rigorous way
COM_Release(punk1:=COM_QueryInterface(NumGet(NumGet(prms+0)+24),0))
COM_Release(punk2:=COM_QueryInterface(NumGet(sink+12),0))
If (punk1 = punk2)
SetTimer, OnComplete, -10
*/
}
|
| [/code] |
|
| Back to top |
|
 |
LinkeR Guest
|
Posted: Wed Aug 18, 2010 4:40 pm Post subject: COMMENT |
|
|
Hi there
Now that I have finally find this helpful site . I am pretty stunned I mean, thses notes are so damn useful. I think I hafta get my Viagra Online Without prescription in order to find such a nice way to feel fine!
Keep it up! |
|
| Back to top |
|
 |
Gauss
Joined: 10 Sep 2009 Posts: 203
|
|
| Back to top |
|
 |
rarva
Joined: 04 Sep 2009 Posts: 5
|
Posted: Sat Aug 21, 2010 2:37 pm Post subject: |
|
|
I am trying to use the IEReady function (I have included a snippet of my code below) immediately after a SendInput command but it will only work properly if I have a Sleep command in the middle. If I don't include the Sleep command then the IEReady function seems to be executed before the SendInput command has executed completely.
While, innerlooprequired
{
ControlFocus, Edit1, ahk_class IEFrame
ControlGetFocus, controlwithfocus
If (controlwithfocus="Edit1")
innerlooprequired=0
}
SendInput, %A_LoopReadLine%{ENTER}
Sleep, 1000
IEReady() |
|
| Back to top |
|
 |
MacroMan!
Joined: 28 Aug 2009 Posts: 595 Location: Brighton, UK
|
Posted: Thu Sep 30, 2010 8:56 am Post subject: |
|
|
| rarva wrote: | I am trying to use the IEReady function (I have included a snippet of my code below) immediately after a SendInput command but it will only work properly if I have a Sleep command in the middle. If I don't include the Sleep command then the IEReady function seems to be executed before the SendInput command has executed completely.
While, innerlooprequired
{
ControlFocus, Edit1, ahk_class IEFrame
ControlGetFocus, controlwithfocus
If (controlwithfocus="Edit1")
innerlooprequired=0
}
SendInput, %A_LoopReadLine%{ENTER}
Sleep, 1000
IEReady() |
I think you need to include the title of the window in the ():
| Code: | | IEReady("Pagetitle") |
|
|
| 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
|