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