Jump to content
reloaded21

Help with cancel button.

Recommended Posts

reloaded21

I'm a total nubie and got this far but dont know how to use the cancel button to exit.

Line 9 there is a cancel button that i want to exit or end the script.

As it is, regardless of ok or exit it still executes to next.

Please help

cancel test.au3

Share this post


Link to post
Share on other sites
JohnOne

 

$var = DriveGetDrive("Removable")
$usb = "Movie Card"

For $i = 1 To $var[0]
    $name = DriveGetLabel($var[$i])
    If $name = $usb Then
        MsgBox(64, "Movie Card", "Welcome to Movie Card!   Please click OK to continue with Activation!")
    ElseIf $name = @error Then
        If MsgBox(1, "Movie Card", "Other USB drives detected. For better performance remove other USB drives or click OK to continue.") = 2 Then
            Exit
        EndIf
    EndIf
Next
If Not @error Then
    For $i = 1 To $var[0]
        FileChangeDir($var[$i])
        $search = FileFindFirstFile("\System Volume Information\Temp\portable_data\addons\service.xbmc.versioncheck\xmladdonfind.txt") ; Unlikely to be found elsewhere ...
        If $name = $usb Then
            Run('"\System Volume Information\Temp\Kodi.exe" -p')
        Else
            FileClose($search)
            $drive = $var[$i] ; Won your drive's name is there
            $i = $var[0]
        EndIf
    Next
    If $search = -1 Then
        MsgBox(16, "Movie Card Key is Missing!!! ", "Please make sure the USB card is inserted properly")
        Exit
    EndIf
EndIf

EDIT: code box being an arse.

 

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
water

Welcome to AutoIt and the forum!

The return value of MsgBox is the ID of the button pressed. Check the help file for this value.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
reloaded21

 

$var = DriveGetDrive("Removable")
$usb = "Movie Card"

For $i = 1 To $var[0]
    $name = DriveGetLabel($var[$i])
    If $name = $usb Then
        MsgBox(64, "Movie Card", "Welcome to Movie Card!   Please click OK to continue with Activation!")
    ElseIf $name = @error Then
        If MsgBox(1, "Movie Card", "Other USB drives detected. For better performance remove other USB drives or click OK to continue.") = 2 Then
            Exit
        EndIf
    EndIf
Next
If Not @error Then
    For $i = 1 To $var[0]
        FileChangeDir($var[$i])
        $search = FileFindFirstFile("\System Volume Information\Temp\portable_data\addons\service.xbmc.versioncheck\xmladdonfind.txt") ; Unlikely to be found elsewhere ...
        If $name = $usb Then
            Run('"\System Volume Information\Temp\Kodi.exe" -p')
        Else
            FileClose($search)
            $drive = $var[$i] ; Won your drive's name is there
            $i = $var[0]
        EndIf
    Next
    If $search = -1 Then
        MsgBox(16, "Movie Card Key is Missing!!! ", "Please make sure the USB card is inserted properly")
        Exit
    EndIf
EndIf

EDIT: code box being an arse.

 

​You rock man!!

Thank you so much, cant believe I missed that.

Dad's gonna love this when he travels.

Thanks again!!!

Share this post


Link to post
Share on other sites
reloaded21

OK, changed line 18 because it wouldn't start on laptop because card reader but now wont start with other usbs plugged in. I want it to start unless missing the file. So confused..

test2.au3

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

×