AutoHotkey Community

It is currently May 27th, 2012, 3:27 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 119 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8
Author Message
PostPosted: October 12th, 2009, 2:36 pm 
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


Report this post
Top
  
Reply with quote  
PostPosted: October 12th, 2009, 2:43 pm 
Offline

Joined: July 4th, 2009, 6:53 pm
Posts: 36
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


Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 12th, 2009, 3:52 pm 
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 --- )))


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 12th, 2009, 3:57 pm 
Offline

Joined: July 4th, 2009, 6:53 pm
Posts: 36
PM me your code, this is increasingly becoming the inappropriate forum for your issue.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2009, 4:49 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
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, :lol:

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2009, 9:06 am 
Offline

Joined: October 9th, 2009, 8:36 pm
Posts: 93
wow i really need this!

thanks, bookmarked!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 30th, 2010, 10:49 pm 
Offline

Joined: July 9th, 2009, 1:13 am
Posts: 140
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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 30th, 2010, 11:22 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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
}

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 30th, 2010, 11:29 pm 
Offline

Joined: July 9th, 2009, 1:13 am
Posts: 140
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?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: June 10th, 2010, 4:25 pm 
Offline

Joined: March 27th, 2009, 3:32 am
Posts: 24
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]


Report this post
Top
 Profile  
Reply with quote  
 Post subject: COMMENT
PostPosted: August 18th, 2010, 5:40 pm 
Hi there 8)

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!


:P Keep it up!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 21st, 2010, 2:59 pm 
Offline

Joined: September 10th, 2009, 5:54 pm
Posts: 203
A work around for Firefox users
http://forums.mozillazine.org/viewtopic ... start=1635


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 21st, 2010, 3:37 pm 
Offline

Joined: September 4th, 2009, 12:55 pm
Posts: 5
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()


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 30th, 2010, 9:56 am 
Offline

Joined: August 28th, 2009, 11:17 am
Posts: 599
Location: Brighton, UK
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")


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 119 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Stigg, xXDarknessXx and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group