Chimaera Posted August 2, 2011 Posted August 2, 2011 Ok Im messing about with arrays atm Two scripts one without works fine second one i cant separate the array elements expandcollapse popup;~ origanal authour Damien #include <GUIConstantsEx.au3> $gui_start = GUICreate("Tools Test ", 200, 250) $CheckBox1 = GUICtrlCreateCheckbox("Program 1 ....", 20, 20, 150) $CheckBox2 = GUICtrlCreateCheckbox("Program 2 ....", 20, 45, 150) $CheckBox3 = GUICtrlCreateCheckbox("Program 3 ....", 20, 70, 150) $CheckBox4 = GUICtrlCreateCheckbox("Program 4 ....", 20, 95, 150) $CheckBox5 = GUICtrlCreateCheckbox("Program 5 ....", 20, 120, 150) $SubmitButton = GUICtrlCreateButton("Submit", 20, 160, 65, 25) GUISetState() While 1 $GuiMsg = GUIGetMsg() Select Case $GuiMsg = $Gui_Event_Close Exit Case $GuiMsg = $SubmitButton $CheckBoxStatus1 = GUICtrlRead($CheckBox1) If $CheckBoxStatus1 = $GUI_CHECKED Then MsgBox(0, "CheckBox 1", "Start item 1") EndIf Sleep(500) $CheckBoxStatus2 = GUICtrlRead($CheckBox2) If $CheckBoxStatus2 = $GUI_CHECKED Then MsgBox(0, "CheckBox 2", "Start item 2") EndIf Sleep(500) $CheckBoxStatus3 = GUICtrlRead($CheckBox3) If $CheckBoxStatus3 = $GUI_CHECKED Then MsgBox(0, "CheckBox 3", "Start item 3") EndIf Sleep(500) $CheckBoxStatus4 = GUICtrlRead($CheckBox4) If $CheckBoxStatus4 = $GUI_CHECKED Then MsgBox(0, "CheckBox 4", "Start item 4") EndIf Sleep(500) $CheckBoxStatus5 = GUICtrlRead($CheckBox5) If $CheckBoxStatus5 = $GUI_CHECKED Then MsgBox(0, "CheckBox 5", "Start item 5") EndIf Sleep(500) EndSelect WEnd This works fine with separate checks on which box is checked so for eg it would only start the items checked This one however im stuck at making the separate checks it makes the multi checked/unchecked fine but how do i do them separately? expandcollapse popup;~ origanl author Melba32 #include <GUIConstantsEx.au3> #include <Array.au3> Global $install_1 Global $data_types[6][2] = [[5, 2],[" Program 1 ", 20],[" Program 2 ", 45],[" Program 3 ", 70],[" Program 4 ", 95],[" Program 5", 120]] Global $check_array[$data_types[0][0] + 1] Global $aTotals[$data_types[0][0] + 1] ; This holds the subtotals for each type $hGUI = GUICreate("Tool Test2", 200, 230) ;creation of checkbox array For $i = 1 To $data_types[0][0] $check_array[$i] = GUICtrlCreateCheckbox($data_types[$i][0], 30, $data_types[$i][1], 100, 35) Next $SubmitButton = GUICtrlCreateButton("Submit", 30, 170, 70, 25) GUISetState() ; Set the elements of $aTotals to the subtotals for each type of file - here we simulate this $aTotals[1] = 1 $aTotals[2] = 10 $aTotals[3] = 100 $aTotals[4] = 1000 $aTotals[5] = 10000 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $SubmitButton ; Reset the overall total $label_total = 0 For $i = 1 to $data_types[0][0] ; Look if checkbox checked If GUICtrlRead($check_array[$i]) = $GUI_CHECKED Then ; Add subtotal to the overall total $label_total += $aTotals[$i] EndIf Next ; Now display the result so you can see only the checked totals were added ConsoleWrite($label_total & @CRLF) EndSwitch WEnd Im guessing i need to change the Sumbit Button section but nothing i have tried works Im not sure whether this bit is needed or not? $aTotals[1] = 1 $aTotals[2] = 10 $aTotals[3] = 100 $aTotals[4] = 1000 $aTotals[5] = 10000 So im trying to make the second script output similar to the first, thanks for any help Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
hannes08 Posted August 2, 2011 Posted August 2, 2011 Hi Chimaera, this works for me: ... $label_total = "" For $i = 1 to $data_types[0][0] ; Look if checkbox checked If GUICtrlRead($check_array[$i]) = $GUI_CHECKED Then ; Add subtotal to the overall total $label_total = 1 & $label_total Else $label_total = 0 & $label_total EndIf Next ... Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Chimaera Posted August 2, 2011 Author Posted August 2, 2011 Sorry m8 i dont understand that works for me the same as the example i gave I need to seperate the 5 checkboxes from the array so i end up with similar to these $CheckBoxStatus4 = GUICtrlRead($CheckBox4) If $CheckBoxStatus4 = $GUI_CHECKED Then MsgBox(0, "CheckBox 4", "Start item 4") EndIf Or is it just easier to not use the array? Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
hannes08 Posted August 2, 2011 Posted August 2, 2011 Hi Chimaera, at the end you have a string of 0's and 1's. So you can loop through the string (or the array) and decide by the current ID whether it needs to be launched or not. e.g. 10101 => Items 1, 3 and 5 need to be lauched e.g. 11001 => Items 1, 4 and 5 need to be lauched Actually it's easier to use arrays than writing 5 or more if - statements... Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
wakillon Posted August 2, 2011 Posted August 2, 2011 (edited) What do you mean by "how do i do them separately?" Edit : you can use _StringReverse ( StringFormat ( "%05u", $label_total ) ) for get it with 5 digits Edited August 2, 2011 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
hannes08 Posted August 2, 2011 Posted August 2, 2011 ... $label_total = "" For $i = 1 to $data_types[0][0] ; Look if checkbox checked If GUICtrlRead($check_array[$i]) = $GUI_CHECKED Then ; Add subtotal to the overall total MsgBox(0, "CheckBox " & $i, "Start item " & $i) $label_total = 1 & $label_total Else $label_total = 0 & $label_total EndIf Next ... Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Chimaera Posted August 2, 2011 Author Posted August 2, 2011 (edited) The problem bit i have is how to launch the items from the numbers eg 10101 that's the bit i don't understand Sorry Wakillon ive tried adding that but keeps giving me an undefined function error does it need an #include of some sort? While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $SubmitButton ; Reset the overall total $label_total = "" For $i = 1 to $data_types[0][0] ; Look if checkbox checked If GUICtrlRead($check_array[$i]) = $GUI_CHECKED Then ; Add subtotal to the overall total MsgBox(0, "CheckBox " & $i, "Start item " & $i) $label_total = 1 & $label_total Else $label_total = 0 & $label_total EndIf Next ConsoleWrite($label_total & @CRLF) EndSwitch WEnd EDIT Ok i see the msgbox now but how can i tie 5 individual intallers for eg to each of the 5 checkboxes like in the first eg i gave? Im getting the impression im not explaining myself very well I suppose mine needs to be more MsgBox(0, "CheckBox " & 1, "Start item " & 1) ]MsgBox(0, "CheckBox " & 2, "Start item " & 2) Edited August 2, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
guinness Posted August 2, 2011 Posted August 2, 2011 The Function needs the include String.au3. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
hannes08 Posted August 2, 2011 Posted August 2, 2011 _StringReverse needs the string.au3 as an include. #include <string.au3> $string = "11101" $string = _StringReverse($string) $a_temp = StringSplit($string,"") For $i = 1 To $a_temp[0] If $a_temp[$i] = 1 Then MsgBox(0, "CheckBox " & $i, "Start item " & $i) Next Or: #include <string.au3> $string = "11101" $a_temp = StringSplit($string,"") For $i = $a_temp[0] To 1 Step -1 If $a_temp[$i] = 1 Then MsgBox(0, "CheckBox " & $i, "Start item " & $i) Next Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Chimaera Posted August 2, 2011 Author Posted August 2, 2011 Im sorry gents, thanks for the help but im just getting more and more confused, ill just do it the hard way as i cant grasp what your telling me Either i cant describe what im doing or i just don't get it Thanks very much for trying to help Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
hannes08 Posted August 2, 2011 Posted August 2, 2011 Ahhh, now I understand: Global $data_types[6][3] = [[5, 2],[" Program 1 ", 20, "C:\path\to\installer1.exe"],[" Program 2 ", 45, "C:\path\to\installer2.exe"],[" Program 3 ", 70, "C:\path\to\installer3.exe"],[" Program 4 ", 95, "C:\path\to\installer4.exe"],[" Program 5", 120, "C:\path\to\installer5.exe"]] ... $label_total = "" For $i = 1 to $data_types[0][0] ; Look if checkbox checked If GUICtrlRead($check_array[$i]) = $GUI_CHECKED Then ; Add subtotal to the overall total MsgBox(0, "CheckBox " & $i, "Start item " & $i & @CRLF & $data_types[$i][2]) $label_total = 1 & $label_total Else $label_total = 0 & $label_total EndIf Next Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Chimaera Posted August 2, 2011 Author Posted August 2, 2011 (edited) Aaah that's where i was going wrong then Im assuming "C:\path\to\installer1.exe" for eg can still be set elsewhere with a $install_1 variable? and this bit MsgBox(0, "CheckBox " & $i, "Start item " & $i & @CRLF & $data_types[$i][2]) & $i is the number of the checked box but when there is more than one how does it know to do them separately? and $data_types[$i][2] what is this saying, data types array / any number that's checked and ? whats the last bit for Second dimension maybe? Edited August 2, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
hannes08 Posted August 2, 2011 Posted August 2, 2011 hi Chimaera, there are 100 ways to get where you want. You can set the path with a variable instead of hardly coding it, for example. $i is the number of the checked box but when there is more than one how does it know to do them separately? As you keep the arrays in sync by creating and assigning the values and handles you can say that, for example, $check_array[3] holds the handle that corresponds to $data_types[3][x]. $data_types[$i][2] what is this saying, data types array / any number that's checked and ? whats the last bit for Second dimension maybe? The $data_types[$i][2] holds the string value of the installer for the actual element. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Chimaera Posted August 2, 2011 Author Posted August 2, 2011 One more questions if i may with arrays how do you change things like fonts? I have this Global $data_types[6][3] = [[5, 2],[" Program 1 ", 20, $install_1],[" Program 2 ", 45, $install_2],[" Program 3 ", 70, $install_3],[" Program 4 ", 95, $install_4],[" Program 5", 120, $install_5]] GUICtrlSetFont( $data_types, 8.5, "", "", "Tahoma") But it just ignores the instruction, i also tried with -1 instead of $data_types How do you make it change for the whole array? If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
hannes08 Posted August 2, 2011 Posted August 2, 2011 (edited) The handles to your checkbox items are stored in the "check_array" array. So again in this case you'll need to loop through the array: For $i = 1 To $data_types[0][0] GuiCtrlSetFont($check_array[$i], 8.5, "", "", "Tahoma") Next Set a single Font: GuiCtrlSetFont($check_array[2], 8.5, 800, 2, "Tahoma") Edited August 2, 2011 by Hannes123 Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
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