Sign in to follow this  
Followers 0
snn

Need help

2 posts in this topic

#1 ·  Posted (edited)

I have my script set to ask if a user has D: as their cd drive. If I hit "No," it opens the second GUI and then closes a second after. How can I fix this?

if ($msgbox = 6) Then
        $drive = "D:"
    ElseIf ($msgbox = 7) Then
        $example = GUICreate("Select Drive", 471, 129, 193, 115)
        $drive = GUICtrlCreateInput("E:", 32, 16, 409, 21); E: Default for users that do not use D: as their CD Drive
        $ok = GUICtrlCreateButton("Apply", 136, 56, 201, 41, 0)
        GUISetState(@SW_SHOW)
    EndIf

Thanks,

Billy

Edited by snn

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Without seeing the rest of the layout of your script it sort of makes it hard to give a definate answer to help.

Off track suggestion:

Why not use DriveGetDrive("CDROM") and then use the return to poulate a ComboBox with the style of $CBS_DROPDOWNLIST. This way a user can only select a CD Rom letter that's available on their system..

Imho it would offer less room for user interaction error with your script.

Cheers

Edit:

#include <GUIConstants.au3>

$example = GUICreate("Select Drive", 471, 129, 193, 115)
$drive = GUICtrlCreateCombo("", 32, 16, 409, 21, $CBS_DROPDOWNLIST)
$ok = GUICtrlCreateButton("Apply", 136, 56, 201, 41, 0)
GUISetState(@SW_HIDE, $example)

AskDefault()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ok
            MsgBox(0, "You have Selected..", "Drive Selected as default is: " & GUICtrlRead($drive))
    EndSwitch
WEnd

Func AskDefault()
    If GetDrives() <> "" Then
        $msgbox = MsgBox(35, "Default Drive?", "Would you like to set " & StringUpper(StringLeft(GetDrives(), 2)) & _
                                " as the default drive?" & @LF & @LF & "Click Yes to use as default drive." & @LF & _
                                "Click No to choose a diferent default drive" & @LF & "Click Cancel to exit script.")
        If ($msgbox = 6) Then
            MsgBox(0, "Default Drive Set", "You have set " & StringUpper(StringLeft(GetDrives(), 2)) & " as the default drive.")
            Exit
        ElseIf ($msgbox = 7) Then
            GUICtrlSetData($drive, StringUpper(GetDrives()), StringUpper(StringLeft(GetDrives(), 2)))
            GUISetState(@SW_SHOW, $example)
        Else
            Exit
        EndIf   
    Else
        Exit
    EndIf
EndFunc 

Func GetDrives()
    Local $sTemp = ""
    Dim $DGD = DriveGetDrive("CDROM")
    If @error <> 1 Then
        For $i = 1 To $DGD[0]
            $sTemp &= $DGD[$i] & "|"
        Next
        Return StringTrimRight($sTemp, 1)
    EndIf
    Return ""
EndFunc
Edited by smashly

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