Jump to content

Recommended Posts

Posted

I have a button on a small gui with 30 checkboxes that starts the final process

The checkboxes contain install switches like this

[settings1]
ms1= -a
ms2= -d
ms3= -e
ms4= -er

Doing this works

If GUICtrlRead($MainCheckbox1) = $GUI_CHECKED Then
                    $SwitchCheck = IniRead(@ScriptDir & "\settings.ini", "settings1", "ms1", "")
                    $AddSwitches &= ' ' & $SwitchCheck
                EndIf
                If GUICtrlRead($MainCheckbox2) = $GUI_CHECKED Then
                    $SwitchCheck = IniRead(@ScriptDir & "\settings.ini", "settings1", "ms2", "")
                    $AddSwitches &= ' ' & $SwitchCheck
                EndIf

But i wanted to automate it so it just loops through and collects all the needed switches

So i came up with this but its not showing the switches

For $n = $MainCheckbox1 To $MainCheckbox30
                        GUICtrlRead($MainCheckbox + $n, $GUI_CHECKED)
                    $SwitchCheck = IniRead(@ScriptDir & "\settings.ini", "settings1", "ms" + $n , "")
                    $AddSwitches &= ' ' & $SwitchCheck
                    Next

Any pointers where i have gone wrong please?

Posted

When creating the checkboxes assign the returned IDs to an array and then loop through this array.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

im holding water's suggestion in reserve atmo until i have worn out mikell's

Onwards another thought, i have set an IniWrite on every time a checkbox is selected so the gui remembers whats done

but it gives a perceptable lurch whilst it is doing the writing .

Am i better to save them to the button at the end so it saves them all as one hit or do a little each time?

i dont want the end to have a huge lurch either really...

Posted

What do you mean by "perceptable lurch"? Half a second, a second?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)

hard to explain

you click the checkbox and the lurch happens so it makes you want to click it again cos you think you didnt catch it.

half a sec maybe before the tick appears

the code to check it is like this

Case $MainCheckbox2
    If GUICtrlRead($MainCheckbox2) = $GUI_CHECKED Then
        IniWrite(@ScriptDir & "\settings.ini", "gui", "g2", "1")
        _UpdateGui()
        GUICtrlSetData($CurrentSettings, "Current Settings = tn.bat" & $AddSwitches)
    Else
        IniWrite(@ScriptDir & "\settings.ini", "gui", "g2", "0")
        _UpdateGui()
        GUICtrlSetData($CurrentSettings, "Current Settings = tn.bat" & $AddSwitches)
    EndIf
                
Func _UpdateGui()
    $AddSwitches = ''
    For $n = 1 To 30
        If GUICtrlRead(Eval("MainCheckbox" & $n)) = $GUI_CHECKED Then
            $SwitchCheck = IniRead(@ScriptDir & "\settings.ini", "main", "ms" & $n, "")
            $AddSwitches &= ' ' & $SwitchCheck
        EndIf
    Next
    For $n = 1 To 10
        If GUICtrlRead(Eval("SecondaryCheckbox" & $n)) = $GUI_CHECKED Then
            $SwitchCheck = IniRead(@ScriptDir & "\settings.ini", "secondary", "ss" & $n, "")
            $AddSwitches &= ' ' & $SwitchCheck
        EndIf
    Next
    ConsoleWrite(@ScriptDir & '\tn.bat' & $AddSwitches & @CRLF)
    Return $AddSwitches
EndFunc   ;==>_UpdateGui

The way ive got it set it updates the Gui at every turn as things change

Edited by Chimaera
Posted

You are doing a lot of processing (CtrlRead and IniRead plus the Eval statements) so I think half a second isn't too bad.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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