Sign in to follow this  
Followers 0
Bertman

INI Value in CheckBox

11 posts in this topic

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.

Share this post


Link to post
Share on other sites



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

WEnd

You 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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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:

#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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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'

Share this post


Link to post
Share on other sites

Anybody ?

Share this post


Link to post
Share on other sites

Bertman,

As I have already told you - use GUICtrlRead:

#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)

EndFunc

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Bertman,

As I have already told you - use GUICtrlRead

But 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.

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Getting this error:

Case $msg >= $var[1][0]

Case $msg >= ^ ERROR

And when I declare the variable, i get:

_ArrayDisplay($var)

^ ERROR

Share this post


Link to post
Share on other sites

Bertman,

Sorry, I left in a debugging line. Here is the whole thing:

#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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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
Sign in to follow this  
Followers 0