Jump to content
Em4gdn1m

combo and checkbox

Recommended Posts

Em4gdn1m

Hey everyone, I'm curious if there is a way to incorporate a checkbox with a combo GUICtrl?

so for instance I have a GUI that has a bunch of checkboxes that allow me to open certain programs as needed.  (this is just some parsing of my code, sorry, noob here and not sure what the preferred method of displaying code is, please enlighten me)


    $L0742 = GUICtrlCreateCheckbox("L07 4.2", 110, 320, 100)
    $L07502 = GUICtrlCreateCheckbox("L07 5.0.2", 110, 350, 100)
    $GenComm = GUICtrlCreateCheckbox("GenComm", 110, 380, 100)
    $Templates = GUICtrlCreateCheckbox("Templates", 110, 410, 100)
    $MCT = GUICtrlCreateCheckbox("MCT", 110, 440, 100)
    $Desktop_Shortcuts = GUICtrlCreateCheckbox("Desktop Shortcuts by Tester", 110, 470, 200)

 

...

Case $msg = $RunBtn
            RunPrograms()

 

...

Func RunPrograms()

    if GUICtrlRead($L0742) = $GUI_CHECKED then Run("C:\Program Files\Varian\Paxscan\L07 Rel4.2\viva\viva.exe", "")
    if GUICtrlRead($L07502) = $GUI_CHECKED then Run("C:\Program Files\Varian\Paxscan\L07 Rel5\viva\viva.exe", "")
    if GUICtrlRead($GenComm) = $GUI_CHECKED then Run("\\Fpanelfs1\FPShared\Desktop_Shortcuts_by_Tester\Matt\CPI Generator\CPI Generator Windows 7 64 Bit\GenComm\GenComm.NET.exe", "")
    if GUICtrlRead($Templates) = $GUI_CHECKED then ShellExecute("\\Fpanelfs1\FPProjects\Documentation Controlled\Test_Templates")
    if GUICtrlRead($MCT) = $GUI_CHECKED then Run("\\Fpanelfs1\FPProjects\Documentation Controlled\Manufacturing Software\MCT\MCT.exe","")
    if GUICtrlRead($Desktop_Shortcuts) = $GUI_CHECKED then ShellExecute("\\Fpanelfs1\fpshared\Desktop_Shortcuts_by_Tester")
EndFunc

 

so i click some checkboxes, and hit a run button and the programs which are checked run, great.

BUT i want to add a bunch of options under one checkbox. A combo that will list a bunch of versions of a program that can be opened. something like this... but I want that program to be part of a checkbox

$ViVAComboBox = GUICtrlCreateCombo("L01 Rel 13", 110, 320, 100)

GUICtrlSetData($ViVAComboBox, "L04|L05|L07 Rel 4.2|L07 Rel 5.0.2|L09", "L07 Rel 4.2")

 

is this possible? is there another GUICtrl that does this better that i am not aware of?

 

 

Share this post


Link to post
Share on other sites
BrewManNH

There isn't a control that combines a checkbox and a combobox, but you could put a checkbox next to one and disable the combo until that check box has been checked.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Em4gdn1m

that sounds like it could work. anything to get me started? still really noob at this stuff.

 

mainly how do i read what is in the combo box and run that specific program?

Edited by Em4gdn1m
clarification

Share this post


Link to post
Share on other sites
Em4gdn1m

so basically I added

While 1

GUICtrlRead($ViVACheckBox)

if GUICtrlRead($ViVACheckBox) = $GUI_CHECKED then GUICtrlSetState($ViVAComboBox, $GUI_ENABLE)

if GUICtrlRead($ViVACheckBox) = $GUI_UNCHECKED then GUICtrlSetState($ViVAComboBox, $GUI_DISABLE)

WEnd

and then

if GUICtrlRead($ViVAComboBox) == "L07 Rel 4.2" then Run("The L07 Rel 4.2 destination here", "")
if GUICtrlRead($ViVAComboBox) == "L01 Rel 13" then Run("The L01 Rel 13 destination here", "")
...

but it's not caring if the combobox is enabled or not. it still just runs the program

and also, the constant checking of the state of the checkbox is kinda weird... id image there is some way to only check the state if the state changes?

Share this post


Link to post
Share on other sites
BrewManNH

This might help clean up the code a bit and make it easier to add additional items later on to the combo box.

While 1
    Switch GUICtrlRead($ViVACheckBox)
        Case $GUI_CHECKED
            GUICtrlSetState($ViVAComboBox, $GUI_ENABLE)
        Case Else
            GUICtrlSetState($ViVAComboBox, $GUI_DISABLE)
    EndSwitch
WEnd
Switch GUICtrlRead($ViVAComboBox)
    Case "L07 Rel 4.2"
        Run("The L07 Rel 4.2 destination here", "")
    Case "L01 Rel 13"
        Run("The L01 Rel 13 destination here", "")
    Case ...
EndSwitch

As to the combo being read regardless of whether it's enabled or not, that's normal. You have to code the script so that it checks whether it needs to read that combobox or not when you go to run your programs.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Em4gdn1m
While 1
    Switch GUICtrlRead($ViVACheckBox)
        Case $GUI_CHECKED
            GUICtrlSetState($ViVAComboBox, $GUI_ENABLE)
        Case Else
            GUICtrlSetState($ViVAComboBox, $GUI_DISABLE)
    EndSwitch
WEnd

This part seems to do nothing with the constant checking of the state, and likewise, nothing different than what I had, though definitely a lot prettier which I like. but there is this constant flashing of the combo box that began when i added my while statement, and didn't stop with yours.

11 minutes ago, BrewManNH said:

 

As to the combo being read regardless of whether it's enabled or not, that's normal. You have to code the script so that it checks whether it needs to read that combobox or not when you go to run your programs.

I tried  doing

if GUICtrlRead($ViVAComboBox) = $GUI_ENABLE & "L07 Rel 4.2" then Run("FILE", "")

;and 

if GUICtrlRead($ViVAComboBox) == $GUI_ENABLE & "L07 Rel 4.2" then Run("file", "")

but neither seemed to work. not sure what to try. I want it to only run if the ViVACheckbox is checked... so

if GUICtrlRead($ViVACheckBox)= $GUI_CHECKED then ;IDK NOW

 

Share this post


Link to post
Share on other sites
Em4gdn1m

 

neither

If GUICtrlRead($ViVACheckBox) = $GUI_ENABLE then
    Switch GUICtrlRead($ViVAComboBox)
        Case "L01 Rel 13"
            Run("C:\Program Files\Speccy\Speccy64.exe", "")
        Case "L04"
            Run("The L01 Rel 13 destination here", "")
        Case "L05"
            Run("The L01 Rel 13 destination here", "")
        Case "L07 Rel 4.2"
            Run("The L01 Rel 13 destination here", "")
        Case "L07 Rel 5.0.2"
            Run("The L01 Rel 13 destination here", "")
        Case "L09"
            Run("The L01 Rel 13 destination here", "")
    EndSwitch
EndIf

nor

If GUICtrlRead($ViVAComboBox) = $GUI_ENABLE then
...

works at opening a program at all

Share this post


Link to post
Share on other sites
Em4gdn1m

actually...

If GUICtrlRead($ViVACheckBox) = $GUI_CHECKED then
        Switch GUICtrlRead($ViVAComboBox)
            Case "L01 Rel 13"
                Run("C:\Program Files\Speccy\Speccy64.exe", "")
            Case "L04"
                Run("The L01 Rel 13 destination here", "")
            Case "L05"
                Run("The L01 Rel 13 destination here", "")
            Case "L07 Rel 4.2"
                Run("The L01 Rel 13 destination here", "")
            Case "L07 Rel 5.0.2"
                Run("The L01 Rel 13 destination here", "")
            Case "L09"
                Run("The L01 Rel 13 destination here", "")
        EndSwitch
    EndIf

worked, now it's just the constant checking of the checkbox. any ideas on that?

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • bowker
      By bowker
      Hi! Is there a way for me to set the value for my slider? I am getting the value for my slider with
       
      Local $strText = _UIA_getPropertyValue($oUIElement, $UIA_LegacyIAccessibleValuePropertyId) MsgBox(0,"",$strText)  
    • nacerbaaziz
      By nacerbaaziz
      Hello
      Can we pause and resume the download in the InetGet function?
      If is possible, what is the solution please?
      I used this code To manage the download

      #include <INet.au3> func _downloader($name, $linc, $filepath, $RTLF = false, $link = false) global $downloader = GUICreate("downloader", 400, 200, -1, -1, $WS_CLIPCHILDREn, $RTLF, $link) global $path = $filePath $labelTxt = GUICtrlCreateLabel("downloading " & $name, 50, 10, 200, 20) global $labelTxt0 = GUICtrlCreateLabel("downloaded size 0 MB " & "OF 0 MB", 50, 60, 300, 20) global $Progress = "" global $sText = ""     For $i = 1 To Random(5, 20, 1) ; Return an integer between 5 and 20 to determine the length of the string.         $sText &= Chr(Random(65, 122, 1)) ; Return an integer between 65 and 122 which represent the ASCII characters between a (lower-case) to Z (upper-case). next global $labelTxt2 = GUICtrlCreateInput("0%", 50, 80, 50, 20) _GUICtrlEdit_SetReadOnly(-1, true) GUIStartGroup("") global $beep = GUICtrlCreateCheckBox("use the progress beep notification", 150, 120, 200, 20) GUIStartGroup("") $button = GUICtrlCreateButton("Cancel', 130, 150, 180, 25, 0x01) $iIndex = 0 global $Target global $url GUIStartGroup("") global $Progress = GUICtrlCreateProgress(50, 90, 150, 20) global $Target = $filepath global $url = $linc global $path = $filepath global $hDownloadNo = _RSMWare_GetData($url, $Target) global $status = false AdlibRegister("SetProgress") global $onprogress = false, $curent = false GUISetState(@sw_Show) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $button $asc = MsgBox(4132,"exit download?","if you click yes the downloading will be cancel, do you want to cancel it ?") if $asc = 6 then AdlibUnRegister("SetProgress") GUIDelete() If $hDownloadNo <> 0 Then InetClose($hDownloadNo) exitLoop endIf EndSwitch if $status = -1 then $status = 0 $hDownloadNo = _RSMWare_GetData($url, $Target) $onprogress = false $curent = false elseIf $Status = 1 then $status = $path GUIDelete() AdlibUnRegister("SetProgress") exitLoop endIf WEnd return $status endFunc Func _RSMWare_GetData($url, $Target) Local $hDownload = InetGet($url, $Target, 1, 1) Return $hDownload EndFunc ;==>_RSMWare_GetData Func SetProgress() Local $state If $hDownloadNo <> 0 Then $state = InetGetInfo($hDownloadNo) If @error = 0 Then $infor = "downloaded size " & Round(Execute(InetGetInfo($hDownloadNo, $INET_DOWNLOADREAD) / 1048576), 2) & " MB of " & Round(Execute(InetGetInfo($hDownloadNo, $INET_DOWNLOADSIZE) / 1048576), 2) & " MB " $onprogress = Round(Ceiling(($state[0] / $state[1]) * 100)) if not (InetGetInfo($hDownloadNo, $INET_DOWNLOADSIZE) = 0) then if $onProgress <= 0 then $onProgress = 0 GUICtrlSetData($Progress, $onProgress) GUICtrlSetData($labelTxt0, $infor) GUICtrlSetData($labelTxt2, $onProgress & "%") if _isChecked($beep) then if $onprogress > $curent then beep((100 + $onprogress * 20), 100) $curent = $onprogress endIf endIf endIf If $state[2] Then If $state[3] Then InetClose($hDownloadNo) $status = 1 else InetClose($hDownloadNo) $status = -1 endIf endIf EndIf endIf EndFunc ;==>SetProgress
    • VollachR
      By VollachR
      Hi,
      I'm looking for a way to take a number value from a Row2 of a 2D array and according to this check if files that appear in rows 3-11 in the array exists.
      For example, if the number in Row2 is 5 I need to check for the files in Row 3-6 only, if it is 6 than rows 3-7 and so on.
      I thought on using a FOR loop but I have very little experience with those.
      Can you suggest the best way to do what I need?
      BTW, the files in Rows 3-11 will usually have blank value for any row above the number in Row2 (e.g. Row2 = 5 so Rows3-6 will have values but 8-11 be empty), The values I need are in Column 1 of the array, the name of the key from the INI file that the array was created from is in Column 0.
      Full Example:
      Row2 of Array:
      Col0 = Games# - Col1 = 5
      Rows3-6
      Col0 = Exe2 - Col1 = Path To File
      Col0 = Exe3 - Col1 = Path To File
      Col0 = Exe4 - Col1 = Path To File
      Col0 = Exe5 - Col1 = Path To File
      I need that if Row2 is 5 to check these above for rows if the file exists, if it was 6 then the next row as well and so on up until number 10 in Row2 as it can't go above 10.
      So basically for whatever number in Row2 from 2-10 need to check 1-9 rows from 3-11 to see if the files in Col1 exists and if any of them don't exist it should call a function that shows an error message.
      I'm pretty sure I have the first line of the for look correct:
      For $i = 1 To $aAIO[2][1] Just not sure how to continue from there, also not sure if $i should be equal 1 or 2.
      Help will be appreciated.
    • VollachR
      By VollachR
      Hi,
      I've written a specialty INI file editor for a specific set of INI files related to a bigger script I'm working on.
      I'm trying to create a verification script that checks the ini files structure and format and gives an error if they are not in expected format.
      What I did so far is create a couple of custom arrays, each with the list of Sections expected in the files and I use IniReadSectionNames in order to read the sections from the selected INI file and compare it to the array.
      It works fine, excepts it only gives an error if one or more of the sections in the custom array is missing, if they all exist but there are other additional sections that shouldn't be there it doesn't give an error and continue to open the editor screen.
      Here are the relevant part of my script:
      The Custom Verification Arrays:
      ;Creating Arrays for INI Verification Global $aSettingsVerify[7] $aSettingsVerify[1] = "Conversion" $aSettingsVerify[2] = "AIO" $aSettingsVerify[3] = "Data" $aSettingsVerify[4] = "Redist" $aSettingsVerify[5] = "Split" $aSettingsVerify[6] = "Autorun" Global $aDataVerify[6] $aDataVerify[1] = "Compression" $aDataVerify[2] = "Exclude" $aDataVerify[3] = "LangExclude" $aDataVerify[4] = "PreCommands" $aDataVerify[5] = "PostCommands" The IniReadSectionNames verification part:
      Case $OK If StringInStr($ActiveConfig, "Settings.ini") Then $CheckArray1 = IniReadSectionNames($ActiveConfig) $CheckArray2 = _ArrayCompare($aSettingsVerify, $CheckArray1) $CheckArray3 = UBound($CheckArray2, 1) If $CheckArray3 = 1 Then GUIDelete($ConfigStart) SettingsGUI() EndIf If $CheckArray3 > 1 Then WrongIni() EndIf EndIf If StringInStr($ActiveConfig, "Data") Then $CheckArray1 = IniReadSectionNames($ActiveConfig) $CheckArray2 = _ArrayCompare($aDataVerify, $CheckArray1) $CheckArray3 = UBound($CheckArray2, 1) If $CheckArray3 = 1 Then GUIDelete($ConfigStart) DataGUI() EndIf If $CheckArray3 > 1 Then WrongIni() EndIf EndIf The Function that performs the compare: (Found it in another thread on this forums somewhere by using Google Search)
      ;Compares Imported INI file with the Verification array Func _ArrayCompare(ByRef $a1, ByRef $a2) Local $nOldSize = UBound($a2) Local $a3[$nOldSize], $nNewSize = $nOldSize For $i = 0 To UBound($a1) - 1 For $j = 0 To $nOldSize - 1 If Not $a3[$j] And ($a1[$i] = $a2[$j]) Then $a3[$j] = 1 $nNewSize -= 1 EndIf Next Next Local $a4[$nNewSize], $j = 0 For $i = 0 To $nOldSize - 1 If Not $a3[$i] Then $a4[$j] = $a2[$i] $j += 1 EndIf Next Return $a4 EndFunc ;==>_ArrayCompare  
      Any way to make a check if there are sections other than the ones in the Verification Array and produce an error?
      Thanks
    • Valnurat
      By Valnurat
      Can you explain why my mouseclick don't work in my shockwave fullscreen.
       
      I know my syntax is ok, because it moves to coordinates, but this will only press 1 time, even that I want to press 5 times.
      How can that be?
×