Jump to content

How can i save the checkbox? then load it when lauch the script?


retaly
 Share

Recommended Posts

  • Moderators

retaly,

Use GUICtrlSetState, not GUICtrlSetData, to check a control. :)

And why does the GUI mode matter? Just run the For...Next loop once you have created the GUI:

For $i = 0 To 2
    If IniRead($sIniFile, "Data", $i, "Not found") = 1 Then
        GUICtrlSetData($aControlID[$i], $GUI_CHECKED)
    EndIf
Next

That assumes you have set the ini value to 1 if the control was checked when you saved the state earlier. ;)

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

 

Link to comment
Share on other sites

it doestn work :/ i share here my currently script because i cant fix it on this way.. :S

i have good ideas for it, but i cant do it.. other things isnt problem.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#include <FTP_Ex.au3>
#include <Misc.au3>

Opt("GUIOnEventMode", 1)

Local $fRun = False
Global $aControlID[4]
Global $sIniFile = @ScriptDir & "\Test.ini"



#Region ### Home FTP-Uploader ~ Settings GUI
$GUI = GUICreate("Home FTP-Uploader ~ Settings", 333, 473, 386, 174)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $GUI)
$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem2 = GUICtrlCreateMenu("Language", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenuItem("English/Angol", $MenuItem2)
$MenuItem5 = GUICtrlCreateMenuItem("Hungary/Magyar", $MenuItem2)
$MenuItem3 = GUICtrlCreateMenuItem("Log", $MenuItem1)
$text_hostn = GUICtrlCreateLabel("Hostname or IP:", 32, 24, 80, 17)
$text_username = GUICtrlCreateLabel("Username:", 56, 56, 55, 17)
$input_hostn = GUICtrlCreateInput("", 112, 24, 185, 21)
$aControlID[0] = $input_hostn

$input_usern = GUICtrlCreateInput("", 112, 56, 185, 21)
$aControlID[1] = $input_usern
$text_passw = GUICtrlCreateLabel("Password:", 56, 88, 53, 17)
$input_passw = GUICtrlCreateInput("", 112, 88, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
$aControlID[2] = $input_passw
$text_choose = GUICtrlCreateLabel("Load:", 80, 120, 31, 17)
$Combo1 = GUICtrlCreateCombo("Combo1", 112, 120, 185, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Connect = GUICtrlCreateButton("Connect", 168, 152, 131, 25)
GUICtrlSetOnEvent(-1, "_connect")
$line = GUICtrlCreateLabel("___________________________________________________", 32, 192, 266, 2, $SS_ETCHEDHORZ)
$button_save = GUICtrlCreateButton("Save Host", 32, 152, 131, 25)
GUICtrlSetOnEvent(-1, "_savesettings")
$status = _GUICtrlStatusBar_Create($GUI)
$text_ftpdir = GUICtrlCreateLabel("Default upload folder:", 32, 200, 105, 17)
$upload_folder = GUICtrlCreateInput("", 136, 200, 161, 21)
GUICtrlSetTip(-1, "for example: testdir/")
$check_getlink = GUICtrlCreateCheckbox("I would like to get link about uploaded files", 64, 224, 233, 17, BitOR($GUI_SS_DEFAULT_CHECKBOX,$BS_RIGHTBUTTON,$BS_RIGHT))
$aControlID[3] =$check_getlink
GUISetState(@SW_SHOW)
#EndRegion ### Home FTP-Uploader ~ Settings GUI

While Sleep(1000)

WEnd


For $i = 0 To 2
GUICtrlSetData($aControlID[$i], IniRead($sIniFile, "Data", $i, "Not found"))
Next
For $i = 3 To 3
GUICtrlSetState($aControlID[$i], IniRead($sIniFile, "Data", $i, "Not found"))

Next


Func _savesettings()
For $i = 0 To 3
IniWrite($sIniFile, "Data1", $i, GUICtrlRead($aControlID[$i]))
Next
EndFunc


Func _connect()
$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, GUICtrlRead($input_hostn), GUICtrlRead($input_usern), GUICtrlRead($input_passw))

If ($Conn <> 0) Then
GUICtrlSetState($input_hostn, $GUI_DISABLE)
GUICtrlSetState($input_usern, $GUI_DISABLE)
GUICtrlSetState($input_passw, $GUI_DISABLE)
$fRun = Not $fRun
If $fRun Then
GUICtrlSetData($Connect, "Disconnect")
Else
GUICtrlSetData($Connect, "Connect")
GUICtrlSetState($input_hostn, $GUI_ENABLE)
GUICtrlSetState($input_usern, $GUI_ENABLE)
GUICtrlSetState($input_passw, $GUI_ENABLE)
EndIf
Else
MsgBox(48, "Home FTP-Uploader", "Could not connected to the server!")
EndIf

_FTPClose($Open)
EndFunc


Func _Exit()
Exit
EndFunc
Edited by retaly
Link to comment
Share on other sites

  • Moderators

retaly,

That script does not work for 3 reasons:

- 1. You try to read the ini file after the idle loop so the code never actually runs. :(

- 2. You save the data under "Data1" and try to read it under "Data". :o

- 3. Your code for resetting the checkbox is nothing like the example I posted above and will not work as written. Why not use the code people post when you ask for help? :huh:

This shortened and amended version of your script works fine for me:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ComboConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>

#include <GuiStatusBar.au3>

Opt("GUIOnEventMode", 1)

Local $fRun = False
Global $aControlID[4]
Global $sIniFile = @ScriptDir & "\Test.ini"

$GUI = GUICreate("Home FTP-Uploader ~ Settings", 333, 473, 386, 174)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $GUI)

$text_hostn = GUICtrlCreateLabel("Hostname or IP:", 32, 24, 80, 17)
$text_username = GUICtrlCreateLabel("Username:", 56, 56, 55, 17)
$input_hostn = GUICtrlCreateInput("", 112, 24, 185, 21)
$aControlID[0] = $input_hostn

$input_usern = GUICtrlCreateInput("", 112, 56, 185, 21)
$aControlID[1] = $input_usern
$text_passw = GUICtrlCreateLabel("Password:", 56, 88, 53, 17)
$input_passw = GUICtrlCreateInput("", 112, 88, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD))
$aControlID[2] = $input_passw
$text_choose = GUICtrlCreateLabel("Load:", 80, 120, 31, 17)
$Combo1 = GUICtrlCreateCombo("Combo1", 112, 120, 185, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
$Connect = GUICtrlCreateButton("Connect", 168, 152, 131, 25)
$line = GUICtrlCreateLabel("___________________________________________________", 32, 192, 266, 2, $SS_ETCHEDHORZ)
$button_save = GUICtrlCreateButton("Save Host", 32, 152, 131, 25)
GUICtrlSetOnEvent(-1, "_savesettings")
$status = _GUICtrlStatusBar_Create($GUI)
$text_ftpdir = GUICtrlCreateLabel("Default upload folder:", 32, 200, 105, 17)
$upload_folder = GUICtrlCreateInput("", 136, 200, 161, 21)
GUICtrlSetTip(-1, "for example: testdir/")
$check_getlink = GUICtrlCreateCheckbox("I would like to get link about uploaded files", 64, 224, 233, 17, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_RIGHTBUTTON, $BS_RIGHT))
$aControlID[3] = $check_getlink
GUISetState(@SW_SHOW)

For $i = 0 To 2
    ConsoleWrite($i & " - " & IniRead($sIniFile, "Data1", $i, "Not found") & @CRLF)
    GUICtrlSetData($aControlID[$i], IniRead($sIniFile, "Data1", $i, "Not found"))
Next
If IniRead($sIniFile, "Data1", 3, "Not found") = 1 Then
    ConsoleWrite("Checked" & @CRLF)
    GUICtrlSetState($aControlID[3], $GUI_CHECKED)
EndIf

While Sleep(1000)

WEnd

Func _savesettings()

    For $i = 0 To 2
        IniWrite($sIniFile, "Data1", $i, GUICtrlRead($aControlID[$i]))
    Next
    If GUICtrlRead($aControlID[3]) = 1 Then
        IniWrite($sIniFile, "Data1", 3, 1)
    Else
        IniWrite($sIniFile, "Data1", 3, 0)
    EndIf

EndFunc   ;==>_savesettings


Func _Exit()
    Exit
EndFunc   ;==>_Exit

All clear now? :)

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

 

Link to comment
Share on other sites

  • Moderators

retaly,

I have absolutely no idea what you are asking - please explain in more detail! :wacko:

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

 

Link to comment
Share on other sites

hi, can i use InputBox like as MsgBox?

MsgBox example,:

$var = msgbox(4, "test", "do you like me?")
If $var = 6 then
msgbox(4, "test", "Thank you :D")
Endif

If $var = 7 then
msgbox(4, "test", ":(")
Endif

hm? :D

i mean, i can fill out one field in inputbox, and it isnt in msgbox, but i need msgbox's function for inputbox, because i want to add an accept option, and one cancel, if cancell then do nothing, if accept then do something..

i hope do u understand, or should i do it with another gui???

Link to comment
Share on other sites

  • Moderators

retaly,

Clear as mud! :D

Do you mean something like this: :huh:

While 1

    $sString = InputBox("Do you like me?", "Well, do you?", "", "", 300, 150)

    Switch $sString
        Case ""
            ; No response so loop round and ask again
        Case "Yes"
            MsgBox(0, "test", "Thank you :D")
            ExitLoop
        Case Else
            MsgBox(0, "test", ":(")
            ExitLoop
    EndSwitch

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

 

Link to comment
Share on other sites

yes, almost.

i know, its hard to find out what i want without source :D

it was my mistake, sry

should to add this option to $additem, because now if i press cancel, it save the data like as if i pres ok.

Func _savesettings()

 $addname = InputBox("Save", "Add a name for the currently host!")

    For $i = 0 To 2
        IniWrite($sIniFile, $addname, $i, GUICtrlRead($aControlID[$i]))
Next
    If GUICtrlRead($aControlID[3]) = 1 Then
        IniWrite($sIniFile, $addname, 3, 1)
    Else
        IniWrite($sIniFile, $addname, 3, 0)
EndIf
GUICtrlSetData($load, $addname)
EndFunc
Link to comment
Share on other sites

  • Moderators

retaly,

So add a check to see what you got as input: ;)

Func _savesettings()

    ; Ask for a host name
    $addname = InputBox("Save", "Add a name for the current host!")
    ; And see what was entered
    Switch $addname
        Case "" ; Nothing entered or cancel pressed
            ; Was cancel pressed?
            If @error = 1 Then
                ; Return an error value and a blank string
                Return SetError(1, 0, "")
            ; So nothing was entered
            Else
                MsgBox(0, "Error", "Please enter a host name")
            EndIf
        Case Else ; Something was entered so save it along with the other data
            For $i = 0 To 2
                IniWrite($sIniFile, $addname, $i, GUICtrlRead($aControlID[$i]))
            Next
            If GUICtrlRead($aControlID[3]) = 1 Then
                IniWrite($sIniFile, $addname, 3, 1)
            Else
                IniWrite($sIniFile, $addname, 3, 0)
            EndIf
            GUICtrlSetData($load, $addname)
            ; Return no error and the name that was entered
            Return SetError(0, 0, $addname)
    EndSwitch
EndFunc   ;==>_savesettings

All clear? :)

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

 

Link to comment
Share on other sites

can delete files from guictrlcreatecombo?

this combo reads from a saved ini file

i mean, right click to one item of combobox's list then -> shows Delete item function, click on it then ->

this function deleting the section from .ini file.

$load = GUICtrlCreateCombo("", 112, 120, 185, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetOnEvent(-1, "_load")



Func _load()

For $i = 0 To 2
ConsoleWrite($i & " - " & IniRead($sIniFile, GUICtrlRead($load), $i, "") & @CRLF)
GUICtrlSetData($aControlID[$i], IniRead($sIniFile, GUICtrlRead($load), $i, ""))
Next
If IniRead($sIniFile, GUICtrlRead($load), 3, "") = 1 Then
ConsoleWrite("Checked" & @CRLF)
GUICtrlSetState($aControlID[3], $GUI_CHECKED)
EndIf
EndFunc
Edited by retaly
Link to comment
Share on other sites

  • Moderators

retaly,

I split this completely unrelated question into a new thread. ;)

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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