inwmsn Posted March 27, 2008 Share Posted March 27, 2008 Hi All I have some problem that I couldn't figure out how to fix the incomplete process. Here my code #include <IE.au3> For $num = 1 to 100 $percent = "%" $status = $num&$percent $text = WinGetText("My program") If StringInStr ($text, $status) Then MsgBox(0,"","COMPLETE") ;;; whenever if 100% process, it's fine but sometime it stuck between 0-99% ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;for example 67% and stop process forever until I have to reprocess again. Else sleep(20) ;;;;;;;;if it is not 100% yet. It will keep looping until 100% But it will loop forever if the process is stucked EndIf Next Can somebody help me. Thanks. Link to comment Share on other sites More sharing options...
Swift Posted March 27, 2008 Share Posted March 27, 2008 ExitLoop Link to comment Share on other sites More sharing options...
Paulie Posted March 27, 2008 Share Posted March 27, 2008 Your code makes no sense to me.. Try this, Do $Text= WinGetText("My Program") Until StringInStr($Text, "100%") MsgBox(0,"","COMPLETE") Link to comment Share on other sites More sharing options...
spudw2k Posted March 27, 2008 Share Posted March 27, 2008 Let me make sure I understand what you're asking for. You want a loop that will check to see if a window has a text value of 1-100% in it and if it finds it then do something? Wouldn't you want to do something like if 100% then complete, else if other percent do something else. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF  Link to comment Share on other sites More sharing options...
Vindicator209 Posted March 27, 2008 Share Posted March 27, 2008 (edited) The way I see it, that script will terminate after it reaches 100, no matter what. I'm not quite sure of your problem here... Edited March 27, 2008 by VindicatorOmega [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center] Link to comment Share on other sites More sharing options...
inwmsn Posted March 27, 2008 Author Share Posted March 27, 2008 Thanks for replying and sorry to make confusing. I want to capture the stream media's the packet through wm recorder. Each streamming take within 20min. to complete. The process will be identify by 0,1,2,3,..100%. If it is 100% mean that file is captured sucessuly then I can capture another file. But If it is not 100% then it sleep(20) which I use looping to check the status until I got 100%. Anyway if there is not any error during capturing everything would be fine. But often it is stopped during capturing such as 57%, 63%, 89%. Then process still keep looping. Because the status still is not 100%. So it will loop forever. Thus I would like to have a condition state to check status that if it is not 100% within 20 min. Then it will recapture again. May be it should look like this. For $num = 1 to 100 $percent = "%" $status = $num&$percent $text = WinGetText("My program") $begin = TimerInit() sleep(1200000) $dif = TimerDiff($begin) If StringInStr ($text, $status) Then MsgBox(0,"","COMPLETE") Else sleep(20) EndIf If Not StringInStr ($text,$status) And ($dif == 0) Then MsgBox(0,"","INCOMPLETE") EndIF Next Thanks Link to comment Share on other sites More sharing options...
inwmsn Posted March 28, 2008 Author Share Posted March 28, 2008 Nobody helping me.. Link to comment Share on other sites More sharing options...
FreeFry Posted March 28, 2008 Share Posted March 28, 2008 Maybe: Dim $oldState = WinGetText("My Program") ; Save the old text(and the percentage it's at) Dim $Timer = TimerInit() ; Start our timer Do Sleep(250) If WinGetText("My Program") <> $oldState Then ; Compare the text in the window with the old, stored text $Timer = TimerInit() ; Restart the timer, the percentage is increasing(hopefully, unless some other text is changing) $oldState = WinGetText("My Program") ; Resave the old text(and the percentage it's at) EndIf Until StringInStr(WinGetText("My Program"), "100%") Or TimerDiff($Timer) > 1200000 ; Will exit the loop if 100% is detected in the window text, OR if the timer runs out(20 minutes) If TimerDiff($Timer) > 1200000 Then ; Checks if the timer did run out MsgBox(0, "Error", "Capture seems like it has hanged!") ;Do something more here? Else ; otherwise it must've finished! MsgBox(0, "Success", "Capture is completed!") EndIf Beware that it will wait 20 minutes from the point it hangs(you could decrease the delay it waits by decreasing the value 1200000), which means if it would freeze at 89% then it would sit there and wait for 20 minutes before timing out.. Link to comment Share on other sites More sharing options...
inwmsn Posted March 28, 2008 Author Share Posted March 28, 2008 Maybe: Dim $oldState = WinGetText("My Program") ; Save the old text(and the percentage it's at) Dim $Timer = TimerInit() ; Start our timer Do Sleep(250) If WinGetText("My Program") <> $oldState Then ; Compare the text in the window with the old, stored text $Timer = TimerInit() ; Restart the timer, the percentage is increasing(hopefully, unless some other text is changing) $oldState = WinGetText("My Program") ; Resave the old text(and the percentage it's at) EndIf Until StringInStr(WinGetText("My Program"), "100%") Or TimerDiff($Timer) > 1200000 ; Will exit the loop if 100% is detected in the window text, OR if the timer runs out(20 minutes) If TimerDiff($Timer) > 1200000 Then ; Checks if the timer did run out MsgBox(0, "Error", "Capture seems like it has hanged!") ;Do something more here? Else ; otherwise it must've finished! MsgBox(0, "Success", "Capture is completed!") EndIf Beware that it will wait 20 minutes from the point it hangs(you could decrease the delay it waits by decreasing the value 1200000), which means if it would freeze at 89% then it would sit there and wait for 20 minutes before timing out.. Wow!!! It's work !!! Thank you very much !!Free Fly ^^ Link to comment Share on other sites More sharing options...
FreeFry Posted March 28, 2008 Share Posted March 28, 2008 No problemo, hope you learn something from it. Link to comment Share on other sites More sharing options...
inwmsn Posted March 29, 2008 Author Share Posted March 29, 2008 Hello FreeFly, your code is work like a charm. However when I add the same code for repeat the task after "Else" statement. It won't work as following; Dim $oldState = WinGetText("My Program") ; Save the old text(and the percentage it's at) Dim $Timer = TimerInit() ; Start our timer Do Sleep(250) If WinGetText("My Program") <> $oldState Then ; Compare the text in the window with the old, stored text $Timer = TimerInit() ; Restart the timer, the percentage is increasing(hopefully, unless some other text is changing) $oldState = WinGetText("My Program") ; Resave the old text(and the percentage it's at) EndIf Until StringInStr(WinGetText("My Program"), "100%") Or TimerDiff($Timer) > 1200000 ; Will exit the loop if 100% is detected in the window text, OR if the timer runs out(20 minutes) If TimerDiff($Timer) > 1200000 Then ; Checks if the timer did run out MsgBox(0, "Error", "Capture seems like it has hanged!") ;Do something more here? Else ; otherwise it must've finished! Dim $oldState = WinGetText("My Program") ; Save the old text(and the percentage it's at) Dim $Timer = TimerInit() ; Start our timer Do ;;;;;;--> somthing wrong in this loop. It skip looping even it wasn't reach to 100% yet. Sleep(250) If WinGetText("My Program") <> $oldState Then ; Compare the text in the window with the old, stored text $Timer = TimerInit() ; Restart the timer, the percentage is increasing(hopefully, unless some other text is changing) $oldState = WinGetText("My Program") ; Resave the old text(and the percentage it's at) EndIf Until StringInStr(WinGetText("My Program"), "100%") Or TimerDiff($Timer) > 1200000 ; Will exit the loop if 100% is detected in the window text, OR if the timer runs out(20 minutes) If TimerDiff($Timer) > 1200000 Then ; Checks if the timer did run out MsgBox(0, "Error", "Capture seems like it has hanged!") ;Do something more here? Else ; otherwise it must've finished! MsgBox(0, "Success", "Capture is completed!") EndIf EndIf Do I miss somthing. Please help Thanks. Link to comment Share on other sites More sharing options...
FreeFry Posted March 29, 2008 Share Posted March 29, 2008 (edited) Try this: Dim $oldState Dim $Timer For $i = 1 To 4; Do this for 4 times $oldState = WinGetText("My Program") $Timer = TimerInit() Do Sleep(250) If WinGetText("My Program") <> $oldState Then $Timer = TimerInit() $oldState = WinGetText("My Program") EndIf Until StringInStr(WinGetText("My Program"), "100%") Or TimerDiff($Timer) > 1200000 Or Not WinExists("My Program") If TimerDiff($Timer) > 1200000 Then MsgBox(0, "Error", "Capture seems like it has hanged!") ;Do something more here? Else ;Do something more here? EndIf Do Sleep(250) Until Not StringInStr(WinGetText("My Program"), "100%") ; this will wait untill the window doesn't have 100% in its text Next It needs to wait untill it doesn't have 100% in its text before the next iteration takes place, otherwise the window would still have 100% inside its text, and finish the loop instantly. Edited March 29, 2008 by FreeFry Link to comment Share on other sites More sharing options...
inwmsn Posted March 31, 2008 Author Share Posted March 31, 2008 Perfect !!!!! It work great!! Thanks again FreeFly 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