Wait until site has finished loading?
I tried the WinExist but the title of the window comes up before the site finishes downloading.
Can AHK wait until firefox fully loads a site before going to the next action?
Thanks!
Fo-
Win7 (x64)
Look up commands faster by using the AutoHotkey Help File's index.
Start→AllPrograms→AutoHotkey→AutoHotkey Help File
I know that there's a lot of info on doing this in Internet Explorer, and I remember even seeing some mentions of how to alter the IE method for use with FireFox.
The basics to help you begin your search, are that it's a COM method.
Sign up for free! http://db.tt/9Hrieqj
WinWait won't work for what the OP wants...
I tested it and it works.
Win7 (x64)
Look up commands faster by using the AutoHotkey Help File's index.
Start→AllPrograms→AutoHotkey→AutoHotkey Help File
Waits until the specified window exists.
Sign up for free! http://db.tt/9Hrieqj
It's not what the OP asked either. :wink:WinWait won't work for what the OP wants...
...
The basics to help you begin your search, are that it's a COM method.
sleep, 2000
after your winwait.
Increase as needed.
Win7 (x64)
Look up commands faster by using the AutoHotkey Help File's index.
Start→AllPrograms→AutoHotkey→AutoHotkey Help File
~Albert Campion
-----------------------------------------------------------------------------------------------
Website | Demo scripts | Blog | External contact
Taken from the following thread:http://www.autohotkey.com/forum/viewtopic.php?t=41447&postdays=0&postorder=asc&highlight=firefox+load&start=30
Code (Collapse): Run, Firefox.exe "www.google.com" WinWaitActive, ahk_class MozillaWindowClass MouseGetPos, x, y, win WinGetClass, class, ahk_id %win% if (class = "MozillaWindowClass") MouseMove, 0, 0, 0 while, FF4StatusBarText() sleep, 10 MsgBox, Page Loaded FF4StatusBarText(hwnd="") { WinGet, hwnd, id, % hwnd? "ahk_id" hwnd:"ahk_class MozillaWindowClass" Win := Acc_ObjectFromWindow(hwnd) Loop, % Win.accChildCount {} until, GetRoleText(Win.accRole(n:=A_Index))= "property page" Loop, % (PropPage:=Win.accChild(n)).accChildCount if (GetRoleText(PropPage.accRole(A_Index)) = "status bar") return, PropPage.accName(A_Index) } GetRoleText(nRole) { ; based on Sean's function from the original ACC Library nSize := DllCall("oleacc\GetRoleTextW", "Uint", nRole, "Uint", 0, "Uint", 0) VarSetCapacity(sRole, nSize*2) DllCall("oleacc\GetRoleTextW", "Uint", nRole, "str", sRole, "Uint", nSize+1) Return sRole }Note - this example uses AutoHotkey_L & the ComUtils Libraries
Sign up for free! http://db.tt/9Hrieqj
Run, Firefox.exe "www.google.com" WinWaitActive, ahk_class MozillaWindowClass MouseGetPos, x, y, win WinGetClass, class, ahk_id %win% if (class = "MozillaWindowClass") MouseMove, 0, 0, 0 while, FF4StatusBarText() sleep, 10 MsgBox, Page Loaded FF4StatusBarText(hwnd="") { WinGet, hwnd, id, % hwnd? "ahk_id" hwnd:"ahk_class MozillaWindowClass" Win := Acc_ObjectFromWindow(hwnd) Loop, % Win.accChildCount {} until, Acc_GetRoleText(Win.accRole(n:=A_Index))= "property page" Loop, % (PropPage:=Win.accChild(n)).accChildCount if (Acc_GetRoleText(PropPage.accRole(A_Index)) = "status bar") return, PropPage.accName(A_Index) }
I was simply trying to get the point across to Honest Abe that there is actually a way to wait for page load, and not just window load in Firefox.
(Edited the mis-quote)
Sign up for free! http://db.tt/9Hrieqj
Error: 0x80070057 - The parameter is incorrect.
Source: (null)
Description: (null)
HelpFile: (null)
HelpContext: 0
Specifically: accRole
Line#
963: SendInput,!fk
964: Return
969: {
970: WinGet,HWnd,ID,HWnd ? "ahk_id " HWnd : "ahk_class MozillaWindowClass"
971: Win := Acc_ObjectFromWindow(HWnd)
972: Loop,Win.accChildCount
973: {
---> 974: }
974: Until,Acc_GetRoleText(Win.accRole(n := A_Index)) = "property page"
975: Loop,(PropPage := Win.accChild(n)).accChildCount
976: if ( Acc_GetRoleText(PropPage.accRole(A_Index)) = "status bar" )
977: Return,PropPage.accName(A_Index)
978: }
985: Run,%Firefox% -new-window <!-- m -->http://mail.google.com/mail/?kbd=1<!-- m -->
986: WinWaitActive,Gmail - Inbox ahk_class MozillaWindowClass
Continue running the script?
---------------------------
Yes No
---------------------------
I am using Windows XP SP3, AHK_L 1.1.05.01, and:Error: 0x80070057 - The parameter is incorrect.
Source: (null)
Description: (null)
HelpFile: (null)
HelpContext: 0
Specifically: accChild
Line#
969: {
970: WinGet,HWnd,ID,HWnd ? "ahk_id " HWnd : "ahk_class MozillaWindowClass"
971: Win := Acc_ObjectFromWindow(HWnd)
972: Loop,Win.accChildCount
973: {
974: }
974: Until,Acc_GetRoleText(Win.accRole(n := A_Index)) = "property page"
---> 975: Loop,(PropPage := Win.accChild(n)).accChildCount
976: if ( Acc_GetRoleText(PropPage.accRole(A_Index)) = "status bar" )
977: Return,PropPage.accName(A_Index)
978: }
985: Run,%Firefox% -new-window <!-- m -->http://mail.google.com/mail/?kbd=1<!-- m -->
986: WinWaitActive,Gmail - Inbox ahk_class MozillaWindowClass
987: WinGet,FF_Handle,ID,A
988: WinMove,ahk_id %FF_Handle%,,(A_ScreenWidth - FF_CAWd_Width) // 2,(A_ScreenHeight - FF_CAWd_Height) // 2,FF_CAWd_Width,FF_CAWd_Height
Continue running the script?
---------------------------
Yes No
---------------------------
Run %Firefox% -new-window http://mail.google.com/mail/?kbd=1 WinWaitActive Gmail - Inbox ahk_class MozillaWindowClass WinGet FF_Handle, ID, A WinMove ahk_id %FF_Handle%, , (A_ScreenWidth - FF_CAWd_Width) // 2 , (A_ScreenHeight - FF_CAWd_Height) // 2 , FF_CAWd_Width, FF_CAWd_Height SendInput {Click 30, 5, 0} While FF4StatusBarText(FF_Handle) Sleep 1000Any help correcting, preventing, or debugging this would be greatly appreciated.
Thanks in advance.
It is rather inelegant, but he could use ImageSearch to determine when the reload button appears in the browser. In Firefox that means the page is done loading.
Interesting... i never thought of that.
FFStatusBarText(hwnd="") { ; tested on FireFox v8 WinGet, hwnd, id, % hwnd? "ahk_id" hwnd:"ahk_class MozillaWindowClass" Win := Acc_ObjectFromWindow(hwnd) for PropPage in Acc_EnumChildren(Win) if Acc_GetRoleText(PropPage.accRole(0))="property page" break for StatusBar in Acc_EnumChildren(PropPage) if Acc_GetRoleText(StatusBar.accRole(0))="status bar" return, StatusBar.accName(0) }
It is rather inelegant, but he could use ImageSearch to determine when the reload button appears in the browser. In Firefox that means the page is done loading.
Interesting... i never thought of that.
It is a clever idea.
I tried pixelsearch instead, and that worked
(waits for white pixels to replace the red ones).
Although, on some websites, certain content continues to load even after the reload button reappears.
Here are two ways I got it to work:
setTitleMatchmode, 2 +space:: run http://www.youtube.com winwait, YouTube while (Px = "") { PixelSearch, Px, Py, 938, 82, 955, 95, 0xFFFFFF, 10, Fast } msgbox, found Px := "" return !space:: run http://www.youtube.com winwait, YouTube loop { PixelSearch, Px, Py, 938, 82, 955, 95, 0xFFFFFF, 10, fast if errorlevel continue else break } msgbox, found return
Win7 (x64)
Look up commands faster by using the AutoHotkey Help File's index.
Start→AllPrograms→AutoHotkey→AutoHotkey Help File