islandspapand Posted May 27, 2011 Posted May 27, 2011 Hello I am a noob to autoit and programming and have just startet a small project. I have run into a problem I hope someone can help me with. I have a GUI with a Inputbox & an Dropdown list(Combo list) And what I want it to do is, when a name in the dropdown list is chosen, the inputbox gets a max charater length. The different names in the dropdown list give different max charater length to the input box. Here is a little exsample of what i have tried: #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $GUIRecovery = GUICreate("Test ", 241, 203, 352, 256) $NextB = GUICtrlCreateButton("Next", 8, 168, 225, 33, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP), $WS_EX_STATICEDGE) $PDROP = GUICtrlCreateCombo("", 28, 32, 97, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData($PDROP, "Asus|Clevo|Dell|Fujitsu|HP|LG|Lenovo|MSI|Medion|Packard Bell|Samsung|Sony|Toshiba|Zepto|") $OSDROP = GUICtrlCreateCombo("Win7", 128, 88, 97, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData($OSDROP, "Vista|XP") $RLabel = GUICtrlCreateLabel(" Model Nr:", 128, 120, 99, 17, $SS_CENTER) $PNAVN = GUICtrlCreateLabel("Vælg PC Proucent", 128, 9, 101, 17) $OSL = GUICtrlCreateLabel("Vælg OS Version", 128, 64, 94, 17) $PDROPSTATE = GUICtrlRead($PDROP,1) $OSDROPSTATE = GUICtrlRead($OSDROP,1) If $PDROPSTATE = "Acer" Then $DskName = GUICtrlCreateInput("", 128, 136, 105, 21,-1) GUICtrlSetLimit($DskName, 5,4) EndIf If $PDROPSTATE = "HP" Then $DskName = GUICtrlCreateInput("", 128, 136, 105, 21,-1) GUICtrlSetLimit($DskName, 10,4) EndIf GUISetState() While 1 $Msg = GUIGetMsg() If $Msg = $GUI_Event_close Then Exit EndIf If $Msg = $NextB Then Exit EndIf WEndHelp.au3
Moderators Melba23 Posted May 28, 2011 Moderators Posted May 28, 2011 islandspapand, Welcome to the AutoIt forum. I have made a few changes to your script and it should now run as you wish: expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> ; Set a couple of Global variables Global $sCurrDROP = "" Global $DskName = 9999 ; This is a placeholder value $GUIRecovery = GUICreate("Test ", 241, 203, 352, 256) $NextB = GUICtrlCreateButton("Next", 8, 168, 225, 33, BitOR($BS_DEFPUSHBUTTON, $WS_GROUP), $WS_EX_STATICEDGE) $PDROP = GUICtrlCreateCombo("", 28, 32, 97, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData($PDROP, "Asus|Clevo|Dell|Fujitsu|HP|LG|Lenovo|MSI|Medion|Packard Bell|Samsung|Sony|Toshiba|Zepto|") $OSDROP = GUICtrlCreateCombo("Win7", 128, 88, 97, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData($OSDROP, "Vista|XP") $PNAVN = GUICtrlCreateLabel("Vælg PC Proucent", 128, 9, 101, 17) $OSL = GUICtrlCreateLabel("Vælg OS Version", 128, 64, 94, 17) GUISetState() While 1 ; Better syntax for your GUIGetMsg loop ! Switch GUIGetMsg() Case $GUI_Event_close Exit Case $NextB Exit Case $PDROP ; The combo edit was changed ; Check if combo has been altered and closed If GUICtrlRead($PDROP) <> $sCurrDROP Then ; Create the label and input the first time we use the combo If $DskName = 9999 Then $RLabel = GUICtrlCreateLabel(" Model Nr:", 128, 120, 99, 17, $SS_CENTER) $DskName = GUICtrlCreateInput("", 128, 136, 105, 21, -1) EndIf ; Check combo value Switch GUICtrlRead($PDROP) Case "Asus" ConsoleWrite("Asus" & @CRLF) ; just for info ; Adjust input limit as required GUICtrlSetLimit($DskName, 5, 4) Case "HP" ConsoleWrite("HP" & @CRLF) ; just for info ; Adjust input limit as required GUICtrlSetLimit($DskName, 10, 4) EndSwitch ; Reset the current combo value $sCurrDROP = GUICtrlRead($PDROP) EndIf EndSwitch $OSDROPSTATE = GUICtrlRead($OSDROP, 1) WEnd I think the comments are self-explanatory, but please ask if not. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
islandspapand Posted May 28, 2011 Author Posted May 28, 2011 M23 Thank you for the welcome and even more thanks for your help I really appreciate it. It was exactly what I needed to move forward I'll soon be posting my full script and i would appreciate it if you would look it over for any noob mistakes or if any process could be done easier. Again thanks for your help and your time. islandspapand.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now