Jump to content

Need an "On cancel" type of code for a script, pls.


Recommended Posts

I have this script which works just great:

"

; minimize all windows

WinMinimizeAll ( )

Run('explorer.exe /n /m,"C:\PROGRA~1\BKP\MOBV2~1.1\MOBV2.EXE"')

WinWait("My Own Backup v2.1","")

Run('explorer.exe /n /m,"D:\0-PROG~1\0-ZIPP~4.2\BACKUP~1"')

WinWait("D:\0- PROGRAMS\0- Zipped file)","")

Run('explorer.exe /n /m,"C:\PROGRA~1\DIARY\DIARYV~1.2_T\THEDIARY.EXE"')

Exit

; finished

"

I'm just stuck on putting in a cancel code. I compiled this little script and then set my reminder program to launch this at a certain time each day. If I press cancel on the box that comes up, though, the script just pauses in the systray and I have to right-click on it to manually cancel. Is there a way to enter some sort of "on cancel" then go to the exit? I've looked in the help file and then looked through a ton of example scripts here in this forum but I'm just terrible at scripts that I couldn't recognize anything that would work.

Thanks in advance for any help. Know this will probably be a very simple thing for many here, but it's beyond me. Cheers!

Link to comment
Share on other sites

I'm not sure whether this is what you're after, but you might like to place it at the top of your code and see if it gives the desired result:

If MsgBox(0x41, 'Backup Script', 'Backup will start in 10 seconds unless cancelled.', 10) = 2 Then Exit

Edit: Oops.

Edited by LxP
Link to comment
Share on other sites

WinWait("D:\0- PROGRAMS\0- Zipped file)","")

its stuck on winwait

do something like this

$stop = 0
; minimize all windows
WinMinimizeAll ( )

Run('explorer.exe /n /m,"C:\PROGRA~1\BKP\MOBV2~1.1\MOBV2.EXE"')
WinWait("My Own Backup v2.1",10)

if not winexists("My Own Backup v2.1") then
$stop = msgbox(0,"exit","do you want to exit?")
endif

if $stop = 6 then
exit
endif

Run('explorer.exe /n /m,"D:\0-PROG~1\0-ZIPP~4.2\BACKUP~1"')
WinWait("D:\0- PROGRAMS\0- Zipped file)",10)

if not winexists("D:\0- PROGRAMS\0- Zipped file)") then
$stop = msgbox(0,"exit","do you want to exit?")
endif

if $stop = 6 then
exit
endif


Run('explorer.exe /n /m,"C:\PROGRA~1\DIARY\DIARYV~1.2_T\THEDIARY.EXE"')

Exit
; finished
Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

Diana, what do these lines do:

Run('explorer.exe /n /m,"C:\PROGRA~1\BKP\MOBV2~1.1\MOBV2.EXE"')
Run('explorer.exe /n /m,"D:\0-PROG~1\0-ZIPP~4.2\BACKUP~1"')
Run('explorer.exe /n /m,"C:\PROGRA~1\DIARY\DIARYV~1.2_T\THEDIARY.EXE"')

Do they achieve the same thing as this? --

Run("C:\PROGRA~1\BKP\MOBV2~1.1\MOBV2.EXE")
Run("D:\0-PROG~1\0-ZIPP~4.2\BACKUP~1")
Run("C:\PROGRA~1\DIARY\DIARYV~1.2_T\THEDIARY.EXE")
Link to comment
Share on other sites

wait even better

WinMinimizeAll ( )

Run('explorer.exe /n /m,"C:\PROGRA~1\BKP\MOBV2~1.1\MOBV2.EXE"')
WinWait("My Own Backup v2.1","",5)

adlibenable("stop")


Run('explorer.exe /n /m,"D:\0-PROG~1\0-ZIPP~4.2\BACKUP~1"')
WinWait("D:\0- PROGRAMS\0- Zipped file)","")

Run('explorer.exe /n /m,"C:\PROGRA~1\DIARY\DIARYV~1.2_T\THEDIARY.EXE"')


func stop()
if not winexists("My Own Backup v2.1") then
exit
endfunc

with this code you can terminate the script immediately after the other window closes.. with no user interaction

it will wait 5 seconds after running first program to check if window exists.

you can adjust the time if you want

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

In WinWait() functions use timeout parameter

WinWait("My Own Backup v2.1","",10)

Note: in t0ddie reply is missing second parameter text ""

and after that use WinExists() as in t0ddie reply:

if not winexists("My Own Backup v2.1") then
   if msgbox(4,"exit","do you want to exit?") = 6 then exit
endif

Note: in t0ddie reply is wrong flag number

or directly without messagebox:

if not winexists("My Own Backup v2.1") then exit

You could add this test only at first WinWait or

at all WinWait according to your wishes...

Link to comment
Share on other sites

yeah yeah yeah... lol i usually use scite and then i dont have those simple errors.. it was just written fast here in the forum and was for an idea.. not a copy paste finished code but anyways... it would be easy enough to figure out what was wrong

also yeah.. i didnt remember the flag for yes no on the message box but your right lol

its 4 not 0

lol, i should test this stuff before posting but i was eager to reply .. HA!

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

  • 3 weeks later...

Diana, what do these lines do:

Run('explorer.exe /n /m,"C:\PROGRA~1\BKP\MOBV2~1.1\MOBV2.EXE"')
Run('explorer.exe /n /m,"D:\0-PROG~1\0-ZIPP~4.2\BACKUP~1"')
Run('explorer.exe /n /m,"C:\PROGRA~1\DIARY\DIARYV~1.2_T\THEDIARY.EXE"')

Do they achieve the same thing as this? --

Run("C:\PROGRA~1\BKP\MOBV2~1.1\MOBV2.EXE")
Run("D:\0-PROG~1\0-ZIPP~4.2\BACKUP~1")
Run("C:\PROGRA~1\DIARY\DIARYV~1.2_T\THEDIARY.EXE")
Alex, you're not going to believe this ... <lol> Even though I never responded, weeks later your msg still was at the back of my mind. I tried the "on cancel", etc., responses here and they worked well to a great limit, but something was wrong. And I'm so crazy with work that it took me all these weeks later to figure out last weekend that I was sure something was wrong in my code. Your post pointed me in the right direction. I mistakenly used code I had to open explorer windows maximized instead of my much less frequently used code of opening an app maximized. I hunted down the other code and switched if for the wrong code and this week have had this working perfectly. I have this AI file in a launcher that launches my journal app, the backup app and the fldr every evening. No more error msgs or anything <g>.

Thanks for pointing me in the right direction without my realizing it! <g>

The main lines of the code now look like this:

************************************************

[snip]

Run('explorer.exe /n /m,"D:\0-PROG~1\0-ZIPP~4.2\BACKUP~1"')

WinWait("D:\0- PROGRAMS\0- Zipped file - diary, The Diary v2.2\BACKUPS (unzip files to DATA fldr)")

Run("C:\PROGRA~1\BKP\MOBV2~1.1\MOBV2.EXE", "", @SW_MAXIMIZE)

WinWait("My Own Backup v2.1","")

Run("C:\PROGRA~1\DIARY\DIARYV~1.2_T\THEDIARY.EXE", "", @SW_MAXIMIZE)

[snip]

************************************************

Thank you!!!

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...