mcfr1es Posted August 16, 2004 Share Posted August 16, 2004 (edited) any idea why the following code doesnt work?? I am trying to wait until a ie page is loaded. Func WinWaitWeb($szTitle) Dim $a = 0 While 1 If StatusBarGetText($szTitle) == "Done" Then $a = $a + 1 traytip ("A =", $a, 5, 1) Else $a = 0 EndIf Sleep(500) If $a = 4 Then ExitLoop Wend EndFuncand i Just call it like this: WinWaitWeb("Google") Edited August 16, 2004 by mcfr1es Roger! You son of a big pile o' Monkey Nuts. Link to comment Share on other sites More sharing options...
wcballance Posted August 30, 2004 Share Posted August 30, 2004 (edited) This thread helped me out. I modified the original code to create a slightly more robust function. Here's the code: expandcollapse popup; MyWinWaitWeb Function ; ; Description: Waits for Window Title to change to specified text and then ; monitors status bar for the page, waiting for a "Done" message. ; A timeout value keeps the function from getting caught in an ; endless loop. Status is displayed in system tray. Returns a ; value of 1 if page loads or 0 if page fails to load in time. ; ; $WinTitle = Window Title of web page to monitor ; $TimeOut = amount of time in seconds to wait before returning control to program ; if web page never reports "Done" Func MyWinWaitWeb($WinTitle, $TimeOut) $timer = 0; stores amount of time in milliseconds $countdown = $TimeOut * 1000; start countdown with timeout value in milliseconds $timer_handle = TimerStart() $return = WinWaitActive($WinTitle, "", $TimeOut) TrayTip ("Waiting for page to load...", "timeout in " & Int($countdown/1000) & " seconds", 1, 1) If $return = 0 Then TrayTip ("Status", "Web page did not load.", 1, 2) $success = 0 Else While 1 If StatusBarGetText($WinTitle, "") == "Done" Then TrayTip ("Status", "Web page loaded.", 1, 1) $success = 1 ExitLoop EndIf TrayTip ("Waiting for page to load...", "timeout in " & Int($countdown/1000) & " seconds", 1, 1) Sleep(500) $timer = $timer + TimerStop($timer_handle) If ($timer / 1000) >= $TimeOut Then TrayTip ("Status", "Timing out....", 1, 2) $success = 0 ExitLoop EndIf $timer_handle = TimerStart() $countdown = ($TimeOut * 1000) - $timer Wend EndIf $dummy = TimerStop($timer_handle); make sure timer is stopped Return $success EndFunc Maybe it will be of use to someone out there. -Will Ballance Edited August 30, 2004 by wcballance Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now