Jump to content

Detecting closed window fails


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
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.

Link to comment
Share on other sites

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
Link to comment
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?

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...