Sign in to follow this  
Followers 0
wfuehrer

Detecting closed window fails

7 posts in this topic

Hi!

I run some actions in a window and want to end this by klicking on [Cancel] in the message box or when the user closed the main window.

;....
;here window is open

$counter = 1
Do
WinActivate("Advertised Programs Monitor")   
MsgBox(0,"Refresh","Refresh " & $counter, 1)
send("!V")
sleep(500)
send("r")
$counter = $counter + 1
$answer = MsgBox(1,"Softwarerefresh", $counter & ".  Refresh in 60 sec." & @crlf _
       & "until [Cancel] is pressed", 58)
if Not WinExists("Advertised Programs Monitor") then ExitLoop
Until $answer = 2
WinKill("Advertised Programs Monitor")
MsgBox(0,"Refresh End", "Refresh End",5)

When i close the main window "Advertised Programs Monitor" the script still runs.

Any ideas?


Wolfgang Führer

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

Hi!

I run some actions in a window and want to end this by klicking on [Cancel] in the message box or when the user closed the main window.

CODE

;....

;here window is open

$counter = 1

Do

WinActivate("Advertised Programs Monitor") 

MsgBox(0,"Refresh","Refresh " & $counter, 1)

send("!V")

sleep(500)

send("r")

$counter = $counter + 1

$answer = MsgBox(1,"Softwarerefresh", $counter & ".  Refresh in 60 sec." & @crlf _

      & "until [Cancel] is pressed", 58)

if Not WinExists("Advertised Programs Monitor") then ExitLoop

Until $answer = 2

WinKill("Advertised Programs Monitor")

MsgBox(0,"Refresh End", "Refresh End",5)

When i close the main window "Advertised Programs Monitor" the script still runs.

Any ideas?

<{POST_SNAPBACK}>

Ok, how about changing

if Not WinExists("Advertised Programs Monitor") then ExitLoop

into

if WinExists("Advertised Programs Monitor") = 0 then ExitLoop

I know it sounds like they say the same thing, but I've had problems with the "Not" function in my code and when I change it around, it works properly. Go figure.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Hmmm, I've just tested the script, and the logic seems sound. When you say the script still runs, do you mean you still see the message boxes popping up?

Share this post


Link to post
Share on other sites

You still have 2 Message boxes stopping the loop. Maybe AdlibEnable to monitor the window?

AdlibEnable('final', 5)

Func final()
   If Not WinExists("Advertised Programs Monitor") Then Exit
EndFunc

Not WinExists works for me? Must be lucky.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Not WinExist always works for me too.

I don't see why the message boxes would be an issue, they have a timeout value... The first is only 1 second, so it goes quite quick, and the second will be closed because the cancel is clicked.

Edited by Chris_1013

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hmmm, I've just tested the script, and the logic seems sound. When you say the script still runs, do you mean you still see the message boxes popping up?

Yes - the message boxes appears every 60 seconds again.

Changing the code in

if WinExists("Advertised Programs Monitor") = 0 then ExitLoop

brings up the same results.

The send in loop is working in the next active window :idiot:

Edited by wfuehrer

Wolfgang Führer

Share this post


Link to post
Share on other sites

Hi!

I found a solution.

if not WinExists("Advertised Programs Monitor","program(s)") then ExitLoop

The other versions are working, too. It is nessecary to add a text part.


Wolfgang Führer

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