Bertman Posted June 9, 2009 Posted June 9, 2009 Hello, I have an ini file [General] 1=Test1 2=Test2 [Test1] Run=C:\windows\system32\calc.exe [Test2] Run=C:\windows\system32\notepad.exe In my code he made a GUI that looks like this: []Test1 []Test2 When I press Test1 He should run the calculator and when I press Test2 he shouls start Notepad. But I don't know how to find the name of the box that was pressed.
Moderators Melba23 Posted June 9, 2009 Moderators Posted June 9, 2009 Bertman,Use GUICtrlRead:#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hCB1 = GUICtrlCreateCheckbox("Test 1", 10, 10, 50, 20) $hCB2 = GUICtrlCreateCheckbox("Test 2", 10, 50, 50, 20) $hButton = GUICtrlCreateButton("Read", 10, 100, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton If GUICtrlRead($hCB1) = 1 Then ConsoleWrite("Read Test1 from ini file" & @CRLF) If GUICtrlRead($hCB2) = 1 Then ConsoleWrite("Read Test2 from ini file" & @CRLF) EndSwitch WEndYou might want to use a group so that only one checkbox can be checked at a time. ;-)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
Bertman Posted June 12, 2009 Author Posted June 12, 2009 Hello, Thats not exacly what i mean. Maybe when you see the script you know what I mean. I don't know how many checkboxes there are comming, you can define that in the INI file. INI file (Stappen\filestructuur.ini): [Algemeen] 1=structuur 2=sequencer [structuur] Naam=File Structuur Aanmaken Klaar=0 Run=C:\WINDOWS\system32\Calc.exe Parameter= [sequencer] Naam=Sequencer Starten Klaar=0 Run=C:\WINDOWS\system32\Calc.exe Parameter= AU3 file: expandcollapse popup#include <GUIConstantsEx.au3> GUICreate("Sequencer") ; will create a dialog box that when displayed is centered ;~ Structuur laden $IniFile=@ScriptDir & "\" & "Stappen\filestructuur.ini" LoadStruc() ;~ Schermopbouw GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd ;~ Structuur laden Func LoadStruc() If FileExists($IniFile) Then $var = IniReadSection($IniFile, "Algemeen") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else $High = 10 For $i = 1 To $var[0][0] $a = IniRead($IniFile, $var[$i][1], "Naam", "iserniet_koiowhfsdhflagg") If $a <> "iserniet_koiowhfsdhflagg" Then $var[$i][1] = GUICtrlCreateCheckbox($a, 10, $High, 200, 20) $High = $High + 18 EndIf Next EndIf Else MsgBox("","Fout.","Configuratiebestand niet gevonden.") Exit EndIf EndFunc
stampy Posted June 12, 2009 Posted June 12, 2009 ControlGetText() will get the text of the control. However it seems better to just store it as you've already read it from the ini.
Bertman Posted June 12, 2009 Author Posted June 12, 2009 I read the INI file section 'Algemeen'. The I read the section that is been found in 'Algemeen' and gets the value 'Naam' from it. With the value Name I made a checkbox. Is it possible to add a hiddenvalue to a checkbox ? When some one checks 'File Structuur Aanmaken' He will read section 'structuur' And will run 'C:\WINDOWS\system32\Calc.exe'
Moderators Melba23 Posted June 15, 2009 Moderators Posted June 15, 2009 Bertman,As I have already told you - use GUICtrlRead:expandcollapse popup#include <GUIConstantsEx.au3> Global $var[1] GUICreate("Sequencer"); will create a dialog box that when displayed is centered ;~ Structuur laden $IniFile=@ScriptDir & "\test.ini" LoadStruc() $hButton = GUICtrlCreateButton("Read", 10, 100, 80, 30) ;~ Schermopbouw GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton For $i = 1 To $var[0][0] If GUICtrlRead($var[$i][0]) = 1 Then RunCode($i) EndIf Next EndSwitch WEnd ;~ Structuur laden Func LoadStruc() If FileExists($IniFile) Then $var = IniReadSection($IniFile, "Algemeen") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else $High = 10 For $i = 1 To $var[0][0] $a = IniRead($IniFile, $var[$i][1], "Naam", "iserniet_koiowhfsdhflagg") If $a <> "iserniet_koiowhfsdhflagg" Then $var[$i][0] = GUICtrlCreateCheckbox($a, 10, $High, 200, 20) $High = $High + 18 EndIf Next EndIf Else MsgBox("","Fout.","Configuratiebestand niet gevonden.") Exit EndIf EndFunc Func RunCode($i) $Run = IniRead($IniFile, $var[$i][1], "Run", "Nothing Found") If $Run <> "Nothing Found" Then RunWait($Run) EndFuncM23 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
Bertman Posted June 15, 2009 Author Posted June 15, 2009 Bertman,As I have already told you - use GUICtrlReadBut thats the problem, I don't want to have another button, to check it.I want to him to take action when someone checks a box and not when someone checks a box and press a button.It's a workflow.
Moderators Melba23 Posted June 15, 2009 Moderators Posted June 15, 2009 Bertman, Replace the relevant section with the following:GUICreate("Sequencer"); will create a dialog box that when displayed is centered ;~ Structuur laden $IniFile=@ScriptDir & "\test.ini" LoadStruc() ;~ Schermopbouw GUISetState() _ArrayDisplay($var) While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE Exit Case $iMsg >= $var[1][0] ConsoleWrite($iMsg & @CRLF) For $i = 1 To $var[0][0] If GUICtrlRead($var[$i][0]) = 1 Then RunCode($i) GUICtrlSetState($var[$i][0], 4) EndIf Next EndSelect WEnd 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
Bertman Posted June 17, 2009 Author Posted June 17, 2009 Getting this error: Case $msg >= $var[1][0] Case $msg >= ^ ERROR And when I declare the variable, i get: _ArrayDisplay($var) ^ ERROR
Moderators Melba23 Posted June 17, 2009 Moderators Posted June 17, 2009 Bertman, Sorry, I left in a debugging line. Here is the whole thing:expandcollapse popup#include <GUIConstantsEx.au3> Global $var[1] GUICreate("Sequencer"); will create a dialog box that when displayed is centered ;~ Structuur laden $IniFile=@ScriptDir & "\test.ini" LoadStruc() ;~ Schermopbouw GUISetState() While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE Exit Case $iMsg >= $var[1][0] ConsoleWrite($iMsg & @CRLF) For $i = 1 To $var[0][0] If GUICtrlRead($var[$i][0]) = 1 Then RunCode($i) GUICtrlSetState($var[$i][0], 4) EndIf Next EndSelect WEnd ;~ Structuur laden Func LoadStruc() If FileExists($IniFile) Then $var = IniReadSection($IniFile, "Algemeen") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else $High = 10 For $i = 1 To $var[0][0] $a = IniRead($IniFile, $var[$i][1], "Naam", "iserniet_koiowhfsdhflagg") If $a <> "iserniet_koiowhfsdhflagg" Then $var[$i][0] = GUICtrlCreateCheckbox($a, 10, $High, 200, 20) $High = $High + 18 EndIf Next EndIf Else MsgBox("","Fout.","Configuratiebestand niet gevonden.") Exit EndIf EndFunc Func RunCode($i) $Run = IniRead($IniFile, $var[$i][1], "Run", "Nothing Found") If $Run <> "Nothing Found" Then RunWait($Run) EndFunc 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
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