Sign in to follow this  
Followers 0
Bert

Msgbox problem

4 posts in this topic

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?

Share this post


Link to post
Share on other sites



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

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0