flxfxp Posted December 19, 2008 Share Posted December 19, 2008 Hello, I'm using a button which creates a new input box. However, I want that input box to have a unique name. How can I make it add a number behind the variable so it will name them uniquely? So it will create with each press of a button: $CaseNum1 = GUICtrlCreateInput("blah", 32, 40, 121, 21) $CaseNum2 = GUICtrlCreateInput("blah", 32, 40, 121, 21) $CaseNum3 = GUICtrlCreateInput("blah", 32, 40, 121, 21) $CaseNum4 = GUICtrlCreateInput("blah", 32, 40, 121, 21) $CaseNum5 = GUICtrlCreateInput("blah", 32, 40, 121, 21) $CaseNum6 = GUICtrlCreateInput("blah", 32, 40, 121, 21) Thanks! Dennis p.s: bonus question: how do i read all these values based on a array? Link to comment Share on other sites More sharing options...
torels Posted December 19, 2008 Share Posted December 19, 2008 (edited) Use Arrays! bonus answer: dim $array[20] ;somethinghere to fill the array For $i=0 to ubound($array)-1 ;for loop for each array element msgbox(0,"",$array[$i]) next cheers Edited December 19, 2008 by torels Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
flxfxp Posted December 19, 2008 Author Share Posted December 19, 2008 hi torels, thank you for your swift answer. I'm kind of new with Autoit, so could you please provide me a concrete example how to implement this? Many thanks, Dennis Link to comment Share on other sites More sharing options...
KaFu Posted December 19, 2008 Share Posted December 19, 2008 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Dim $array[10] ;somethinghere to fill the array Local $msg GUICreate("My GUI") ; will create a dialog box that when displayed is centered For $i = 0 To UBound($array) - 1 ;for loop for each array element GUICtrlCreateLabel($i,10,13 + $i*20) $array[$i] = GUICtrlCreateInput("", 30, 10 + $i*20, 121, 20) Next GUISetState(@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() Â OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26)Â BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16)Â ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
flxfxp Posted December 19, 2008 Author Share Posted December 19, 2008 I created: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Dim $array[10] ;somethinghere to fill the array Local $msg GUICreate("My GUI") ; will create a dialog box that when displayed is centered For $i = 0 To UBound($array) - 1 ;for loop for each array element GUICtrlCreateLabel($i,10,13 + $i*20) $array[$i] = GUICtrlCreateInput("", 30, 10 + $i*20, 121, 20) Next $SendButton = GUICtrlCreateButton("SND", 325, 10, 50, 20) GUISetState(@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $SendButton dim $array[10] ;somethinghere to fill the array For $i=0 to ubound($array)-1 ;for loop for each array element msgbox(0,"",$array[$i]) next Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd GUIDelete() However, its not returning the inputbox value in the msgbox. What is wrong? Link to comment Share on other sites More sharing options...
MrCreatoR Posted December 19, 2008 Share Posted December 19, 2008 its not returning the inputbox value in the msgbox. What is wrong?1) You not should to Dim it again. 2) You need to read the value using GuiCtrlRead(). #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Dim $array[10] ;somethinghere to fill the array GUICreate("My GUI") ; will create a dialog box that when displayed is centered For $i = 0 To UBound($array) - 1 ;for loop for each array element GUICtrlCreateLabel($i,10,13 + $i*20) $array[$i] = GUICtrlCreateInput("", 30, 10 + $i*20, 121, 20) Next $SendButton = GUICtrlCreateButton("SND", 325, 10, 50, 20) GUISetState(@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $SendButton ;dim $array[10] ;somethinghere to fill the array For $i = 0 To UBound($array)-1 ;for loop for each array element MsgBox(0, "", GUICtrlRead($array[$i])) next Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd  Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1  AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ==================================================    AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
KaFu Posted December 19, 2008 Share Posted December 19, 2008 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Dim $array[10] ;somethinghere to fill the array Local $msg GUICreate("My GUI") ; will create a dialog box that when displayed is centered For $i = 0 To UBound($array) - 1 ;for loop for each array element GUICtrlCreateLabel($i, 10, 13 + $i * 20) $array[$i] = GUICtrlCreateInput("", 30, 10 + $i * 20, 121, 20) Next $SendButton = GUICtrlCreateButton("SND", 325, 10, 50, 20) GUISetState(@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $SendButton ;somethinghere to fill the array For $i = 0 To UBound($array) - 1 ;for loop for each array element MsgBox(0, "", GUICtrlRead($array[$i])) Next Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd GUIDelete() Â OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26)Â BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16)Â ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 19, 2008 Share Posted December 19, 2008 Yet another demo, where the array of input control IDs is used to do something functional (modified from KaFu's example): #include <GUIConstantsEx.au3> Global $avInputs[10], $iValNew, $iValOld = 0 GUICreate("My GUI"); will create a dialog box that when displayed is centered For $i = 0 To UBound($avInputs) - 1;for loop for each array element GUICtrlCreateLabel($i, 10, 13 + ($i * 20)) $avInputs[$i] = GUICtrlCreateInput("0", 30, 10 + ($i * 20), 121, 20) Next $Label_Total = GUICtrlCreateLabel("Total = " & $iValOld, 10, 20 * (UBound($avInputs) + 1), 121, 20) GUISetState(@SW_SHOW); will display an empty dialog box ; Run the GUI until the dialog is closed Do $iValNew = 0 For $n = 0 To UBound($avInputs) - 1 $iValNew += Number(GUICtrlRead($avInputs[$n])) Next If $iValNew <> $iValOld Then $iValOld = $iValNew GUICtrlSetData($Label_Total, "Total = " & $iValOld) EndIf Until GUIGetMsg() = $GUI_EVENT_CLOSE Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
flxfxp Posted December 19, 2008 Author Share Posted December 19, 2008 ok, last question: As I mentioned before I use a button to create a new inputbox. This was simplified for you to understand. To get some background on what i would like to do, please look here.Basically i'm slowly building a array, based on if there are cases or not. When i want a extra case, i click the button for it and i want it to:create a tab [got this working]create a inputbox with a unique idcreate a combobox with a unique idcreate a edit box with a unique idIn the end i would like to grab all the filled in inputboxes, comboboxes and editboxes from every tab so i can do stuff with it (in this case, putting it in a email and send it away).How can I fill the array slowly so it won't create 10 inputboxes at once, but one everytime i press a button?Thanks you very much for your support,Dennis Link to comment Share on other sites More sharing options...
Zinthose Posted December 19, 2008 Share Posted December 19, 2008 If you insist on creating dynamic variables you can use Assign() although Arrays are a better fit for controls. Dim $TempID For $i = 1 To 6 $TempID = GUICtrlCreateInput("blah", 32, 40, 121, 21) Assign("CaseNum", $TempID, 2) Next --- TTFN Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 19, 2008 Share Posted December 19, 2008 ok, last question: As I mentioned before I use a button to create a new inputbox. This was simplified for you to understand. To get some background on what i would like to do, please look here. Basically i'm slowly building a array, based on if there are cases or not. When i want a extra case, i click the button for it and i want it to: create a tab [got this working] create a inputbox with a unique id create a combobox with a unique id create a edit box with a unique id In the end i would like to grab all the filled in inputboxes, comboboxes and editboxes from every tab so i can do stuff with it (in this case, putting it in a email and send it away). How can I fill the array slowly so it won't create 10 inputboxes at once, but one everytime i press a button? Thanks you very much for your support, Dennis So you have the IDs of tab, input, combo, and edit. That's four elements for each tab. You can keep that in a 1D array by some basic math: Global $iTab = 0; Tab instance 0 is the first tab Global $avTabControls[$iTab * 4] $avTabControls[($iTab * 4)] = GUICtrlCreateTabItem(...); Tab control ID $avTabControls[($iTab * 4) + 1] = GUICtrlCreateInput(...); Input control ID $avTabControls[($iTab * 4) + 2] = GUICtrlCreateCombo(...); Combo control ID $avTabControls[($iTab * 4) + 3] = GUICtrlCreateEdit(...); Edit control ID The first tab instance is 0, so the controls IDs are at [0] thru [3], the second tab instance is 1, so the IDs are at [4] thru [7], etc. If you are already comfortable with 2D arrays, my preference is to track them that way: Global $avTabControls[3][4] $avTabControls[0][0] = GUICtrlCreateTabItem(...); Tab control ID $avTabControls[0][1] = GUICtrlCreateInput(...); Input control ID $avTabControls[0][2] = GUICtrlCreateCombo(...); Combo control ID $avTabControls[0][3] = GUICtrlCreateEdit(...); Edit control ID The first tab's controls are at [0][0] thru [0][3], then second tab's ID are at [1][0] thru [1][3], etc. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
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