Jump to content

Recommended Posts

Posted

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
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Posted

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
Posted

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.

Posted

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
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Posted

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.

  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Posted

Getting this error:

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

Case $msg >= ^ ERROR

And when I declare the variable, i get:

_ArrayDisplay($var)

^ ERROR

  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...