Jump to content

Recommended Posts

Posted

Im kinda new to this, so please forgive my erroneous ways.

Looking to do the following:

Make a GUI that allows the user to select/type a few things, so that my other script can paste the info into the appropriate fields. So, GUI opens, and the user can choose from 1 of 3 drop-down boxes (no more than 1), and also enter in a 'Discount'. The info would need to be stored in a variable for pasting later. Please help.

Here is what I have so far, but I think I am way off track, and its probably all crap. I am sure there are some easier ways to accomplish this. Feel free to scrap it all.

#include <GUIConstants.au3>

;declare variables for category and discount;; not sure i need this

Dim $val_cat1,$val_discount

GUICreate ( "Select a Category", 400, 300) ; will create a dialog box that when displayed is centered

GUISetState (@SW_SHOW) ; will display an empty dialog box

GUICtrlCreateCombo ("Category 1 Title",10,10, 200)

GUICtrlSetData(-1,"Option 1|Option 2|Option 3") ; add other item; i need 30 options, is the only way to type them all out?

GUICtrlCreateCombo ("Category 2 Title",10,50, 200)

GUICtrlSetData(-1,"Option 1b|Option 2b|Option 3b") ; add other item

GUICtrlCreateCombo ("Category 3 Title",10,90, 200)

GUICtrlSetData(-1,"Option 1c|Option 2c|Option 3c|") ; add other item

$val_discount = GUICtrlCreateInput ( "Enter Discount", 10, 130, 200) ;;think this is wrong too

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend

  • 13 years later...
Posted

@litlmike,

Try this:

#include <GUIConstants.au3>

;declare variables for category and discount;; not sure i need this

$vMainGUI = GUICreate ( "Select a Category", 400, 300) ; will create a dialog box that when displayed is centered
$ButtonExit = GUICtrlCreateButton("Exit", 310, 260, 80, 30)
$ButtonConfirm = GUICtrlCreateButton("Proceed", 220, 260, 80, 30)

$vOptionSelOne = GUICtrlCreateCombo ("Category 1 Title",10,10, 200)
GUICtrlSetData(-1,"Option 1|Option 2|Option 3") ; add other item; i need 30 options, is the only way to type them all out?

$vOptionSelTwo = GUICtrlCreateCombo ("Category 2 Title",10,50, 200)
GUICtrlSetData(-1,"Option 1b|Option 2b|Option 3b") ; add other item

$vOptionSelThree = GUICtrlCreateCombo ("Category 3 Title",10,90, 200)
GUICtrlSetData(-1,"Option 1c|Option 2c|Option 3c|") ; add other item

$val_discount = GUICtrlCreateInput ( "Enter Discount", 10, 130, 200) ;;think this is wrong too
GUISetState (@SW_SHOW) ; will display an empty dialog box

; Run the GUI until the dialog is closed

While 1
    $nMsg = GUIGetMsg()
        Switch $nMsg

            Case $ButtonExit
                Exit

            Case $ButtonConfirm
                ComboRead($vOptionSelOne, $vOptionSelTwo, $vOptionSelThree)

        EndSwitch
Wend

Func ComboRead($Option, $Option2, $Option3) ;This function checks what is chosen in the combobox and stores it as a variable.
            If $Option = $vOptionSelOne Then
                Global $sel = GUICtrlRead($Option)
                    If $sel = "Option 1" Then
                    $sel = "Option 1"
                    ElseIf $sel = "Option 2" Then
                    $sel = "Option 2"
                    ElseIf $sel = "Option 3" Then
                    $sel = "Option 3"
                    EndIf
            EndIf
            MsgBox(0,"","You have selected " & $sel)

            If $Option2 = $vOptionSelTwo Then
                Global $sel2 = GUICtrlRead($Option2)
                    If $sel2 = "Option 1b" Then
                    $sel2 = "Option 1b"
                    ElseIf $sel2 = "Option 2b" Then
                    $sel2 = "Option 2b"
                    ElseIf $sel2 = "Option 3b" Then
                    $sel2 = "Option 3b"
                    EndIf
            EndIf
            MsgBox(0,"","You have selected " & $sel2)

            If $Option3 = $vOptionSelThree Then
                Global $sel3 = GUICtrlRead($Option3)
                    If $sel3 = "Option 1c" Then
                    $sel3 = "Option 1c"
                    ElseIf $sel3 = "Option 2c" Then
                    $sel3 = "Option 2c"
                    ElseIf $sel3 = "Option 3c" Then
                    $sel3 = "Option 3c"
                    EndIf
            EndIf
            MsgBox(0,"","You have selected " & $sel3)

            Global $discount = GUICtrlRead($val_discount)
            MsgBox(0,"","You have selected " & $discount)

EndFunc ;==> ComboRead

Reply to me if this works out for you!

 

Regards,

Supra

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
×
×
  • Create New...