Bert Posted September 20, 2005 Share Posted September 20, 2005 I have a wierd problem. I need to get this programming in a loop. Most of the time it works. When I run it, sometimes the code gets stuck. I need the code to do the following: 1. Run in a loop, but have sleep built in to allow for temporary window name changes while the browser reloads. (The app this program works with is IE based) 2. If the browser window closes, or is directed away from the app, a message box pops up asking if the user wants to reopen Unicenter, close UNPlus, or cancel for the app is reopened, and the user wants to ignore the msgbox. 3. If cancel is selected, the loop restarts. The problem I found is if you click cancel, here is the first attempt to code it: AutoItSetOption("WinTitleMatchMode", 2) $uni = WinExists("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") $bLoop = -1 while $bLoop = -1 $uni = WinExists("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") sleep(1000) if $uni == 0 then $endunplus = msgbox (3+32+0, "Unicenter Service Desk was closed!", "Do you wish to restart Unicenter? Click YES to restart Unicenter, Click NO to close UNPlus.") if $endunplus == 2 then sleep(5000) endif if $endunplus == 7 then exit endif if $endunplus == 6 then runwait( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://usdp/CAisd/pdmweb.exe","") endif wend ;------------------------------------------ I also tried this, but this has the same problem... $uni = WinExists("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") $end = msgbox (3+32+0, "Unicenter Service Desk was closed!", "Do you wish to restart Unicenter?" & @CRLF & "Click YES to restart Unicenter."& @CRLF & "Click NO to close UNPlus."& @CRLF & "Click cancel to disreguard this message") $bLoop = -1 while $bLoop = -1 if $uni == 0 then $end = msgbox (3+32+0, "Unicenter Service Desk was closed!", "Do you wish to restart Unicenter?" & @CRLF & "Click YES to restart Unicenter."& @CRLF & "Click NO to close UNPlus."& @CRLF & "Click cancel to disreguard this message") select case $end == 2 sleep(1000) ;If $uni == 1 then ContinueLoop case $end == 6 runwait( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://usdp/CAisd/pdmweb.exe","") ;If $uni == 1 then ContinueLoop case $end == 7 exit EndSelect Wend ;---------------------------------- THIS IS DRIVING ME CRAZY! It shouldn't be this hard. What am I missing here? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
seandisanti Posted September 20, 2005 Share Posted September 20, 2005 I have a wierd problem. I need to get this programming in a loop. Most of the time it works. When I run it, sometimes the code gets stuck. I need the code to do the following:1. Run in a loop, but have sleep built in to allow for temporary window name changes while the browser reloads. (The app this program works with is IE based)2. If the browser window closes, or is directed away from the app, a message box pops up asking if the user wants to reopen Unicenter, close UNPlus, or cancel for the app is reopened, and the user wants to ignore the msgbox.3. If cancel is selected, the loop restarts. The problem I found is if you click cancel, here is the first attempt to code it:AutoItSetOption("WinTitleMatchMode", 2)$uni = WinExists("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe")$bLoop = -1 while $bLoop = -1 $uni = WinExists("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") sleep(1000) if $uni == 0 then $endunplus = msgbox (3+32+0, "Unicenter Service Desk was closed!", "Do you wish to restart Unicenter? Click YES to restart Unicenter, Click NO to close UNPlus.") if $endunplus == 2 then sleep(5000) endif if $endunplus == 7 then exit endif if $endunplus == 6 then runwait( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://usdp/CAisd/pdmweb.exe","") endif wend;------------------------------------------I also tried this, but this has the same problem...$uni = WinExists("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe")$end = msgbox (3+32+0, "Unicenter Service Desk was closed!", "Do you wish to restart Unicenter?" & @CRLF & "Click YES to restart Unicenter."& @CRLF & "Click NO to close UNPlus."& @CRLF & "Click cancel to disreguard this message")$bLoop = -1 while $bLoop = -1 if $uni == 0 then $end = msgbox (3+32+0, "Unicenter Service Desk was closed!", "Do you wish to restart Unicenter?" & @CRLF & "Click YES to restart Unicenter."& @CRLF & "Click NO to close UNPlus."& @CRLF & "Click cancel to disreguard this message") select case $end == 2 sleep(1000) ;If $uni == 1 then ContinueLoop case $end == 6 runwait( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://usdp/CAisd/pdmweb.exe","") ;If $uni == 1 then ContinueLoop case $end == 7 exit EndSelect Wend ;----------------------------------THIS IS DRIVING ME CRAZY! It shouldn't be this hard. What am I missing here?Right now you have it set to just wait 5 seconds if cancel is clicked, then the same checks run through again. if the window still doesn't exist, you're going to get the box again... instead of a sleep. try this...AutoItSetOption("WinTitleMatchMode", 2) $uni = WinExists("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") while 1 $uni = WinExists("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") sleep(1000) if $uni == 0 then $endunplus = msgbox (3+32+0, "Unicenter Service Desk was closed!", "Do you wish to restart Unicenter? Click YES to restart Unicenter, Click NO to close UNPlus.") if $endunplus == 2 then WinWaitActive("Unicenter ServicePlus","") endif if $endunplus == 7 then exit endif if $endunplus == 6 then runwait( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://usdp/CAisd/pdmweb.exe","") endif wend Link to comment Share on other sites More sharing options...
Bert Posted September 20, 2005 Author Share Posted September 20, 2005 OK, tried your fix. It works better, but when I try to do the following, it still got hung. I added a sleep(3000) after While 1, and I think that fixed it. I'm doing a hard test with trying to break it, but so far, it works. THANKS DUDE!!! note: I added the following on the first line to debug, and it help BIG TIME: AutoItSetOption ("TrayIconDebug", 1) This will tell me where the script is hung, and what I need to fix. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
seandisanti Posted September 20, 2005 Share Posted September 20, 2005 OK, tried your fix. It works better, but when I try to do the following, it still got hung.I added a sleep(3000) after While 1, and I think that fixed it. I'm doing a hard test with trying to break it, but so far, it works. THANKS DUDE!!!note: I added the following on the first line to debug, and it help BIG TIME:AutoItSetOption ("TrayIconDebug", 1)This will tell me where the script is hung, and what I need to fix.np, glad i could help. and that's one option i use frequently with problem scripts 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