Natu Posted March 3, 2011 Share Posted March 3, 2011 (edited) Hello all! I'm new to AutoIt, but not to the programming world. I've only been using it for a couple days now and am at the point of finally exhausted my resources (google/AutoIt forum search) in trying to find the right code, examples, information to figure out how to do this. What I'm looking to do (as I've seen others too) is have a user select any number of items using check boxes. The check boxes are pre-defined and built/filled using an array and reading from a .txt file. The program lists the items/check boxes fine, is able to determine which are checked and displays accordingly upon hitting "execute" button. The only problem I'm really having is linking the "checked" box to a script. I was thinking of making another .au3 file with the scripts so it cuts out code from the main window, but haven't been able to get it to work. It just loops the program even if boxes are unchecked. Is there any way of doing this? The scripts don't have to be ran from a different .au3 file, but I figured it would be easiest and less clutter. Below is the snippet of code I'm using for it to see whether the box is checked or not. I just can't seem to figure out the code to link the checked box to a separate script. GuiSetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $exititem ExitLoop Case $msg = $execute For $count = 0 to 29 If GUICtrlRead($Checkbox[$count]) = $GUI_CHECKED Then MsgBox(0, "Test: " & $count + 1, "Box: " & $aCheckbox[$count]) GUICtrlSetState($Checkbox[$count], $Gui_Unchecked) GUICtrlSetState($Checkbox[$count], $Gui_Disable) Else EndIf Next EndSelect WEnd Any information/help is appreciated! Thanks; Kevin Edited March 3, 2011 by Natu Link to comment Share on other sites More sharing options...
guinness Posted March 3, 2011 Share Posted March 3, 2011 (edited) Maybe this Function will help to see if a Checkbox is Checked >> Func _IsChecked($iControl) Return BitAND(GUICtrlRead($iControl), 1) = 1 EndFunc ;==>_IsChecked Edited March 3, 2011 by guinness 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 Link to comment Share on other sites More sharing options...
Natu Posted March 3, 2011 Author Share Posted March 3, 2011 Hmm, well how is that function any different from what I have? My current code checks to see which ones are checked and the is able to display that. This is what I'm looking to do, in a "psuedo code" - User selects check box #1 - User hits button to execute - Upon button press, the program searches to see which boxes have been checked - For each box checked, the program will run it's linked script/function (ie; run a program) My code is able to determine which are checked just fine, and it currently displays a message box accordingly. The part I am missing is once the program finds the checkbox number, I need to send it to its appropriate function. Example: User selects check box #1, program sees this and sends the code to Script1 (in a different .au3). Example: User selects check box #1 and #5, program sees this and sends the code first to run Scrip1, and once complete runs Script5 (in a different .au3). Sorry if I'm being confusing, or if this isn't even possible to do. I just can't figure it out Link to comment Share on other sites More sharing options...
ZacUSNYR Posted March 3, 2011 Share Posted March 3, 2011 I have a custom install script. I used an ini and set the ini key to the control ID when generating the check boxes via the ini file. Keep all the controls you created in an array and when checking to see if checked, you can look up in the ini file to get the path for the install file. I added the ability to choose the installer type From my ini file I commented... ; To Install Applications ; ; DisplayName=shortname,type of install,executible ; ; Type of Installs ; installer = Run the Install Program command line. ; msi = Run the executible through the Microsoft Installer (used for .msi files mostly) ; shellexecute = Run a VB Script I'm sure there are other ways to do it but that is what worked for me. I actually use the "shortname" for control id. For Office i'd have something like Microsoft Office 2010=msoffice2010,installer, "\\server\share\office10\setup.exe /flags" Loop through the ini - the checkbox would get the controlid of msoffice2010 and have a label of "Microsoft Office 2010" and when checking it, I loop back through the read array and get the executable/installer type. Then pass that on to a function that runs the appropriate installer. Link to comment Share on other sites More sharing options...
Natu Posted March 3, 2011 Author Share Posted March 3, 2011 Ahhh, very interesting Zac. I haven't done much work with .ini files so that's new to me and I'll have to look into it. What you just mentioned is what I'm looking for, and what I have partially done already. Except my array is filling with a .txt file and setting a number to each one, while it makes the check boxes. The only part I'm missing is the "control ID" which you have in the .ini.Thanks for the info and I'll take a look into something like that. Although I'm still open to any other ways 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