retaly Posted January 19, 2013 Posted January 19, 2013 Hy i would like to save the checkbox 's state, and when lauch the script it will be load itself like as before i closed the program. how should to do it?
retaly Posted January 19, 2013 Author Posted January 19, 2013 ye i know, i use it to save fields in inpubox, but how can it save the checkbox state? i dont know that..
retaly Posted January 19, 2013 Author Posted January 19, 2013 i use this option Opt("GUIOnEventMode", 1) and now i cant take it in while For $i = 0 To 2 GUICtrlSetData($aControlID[$i], IniRead($sIniFile, "Data", $i, "Not found")) Next how can i doing it to automatice load??? without while
Moderators Melba23 Posted January 19, 2013 Moderators Posted January 19, 2013 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 NextThat assumes you have set the ini value to 1 if the control was checked when you saved the state earlier. 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
retaly Posted January 19, 2013 Author Posted January 19, 2013 (edited) 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. expandcollapse popup#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 January 19, 2013 by retaly
Moderators Melba23 Posted January 19, 2013 Moderators Posted January 19, 2013 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". - 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? This shortened and amended version of your script works fine for me:expandcollapse popup#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 ;==>_ExitAll clear now? 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
retaly Posted January 19, 2013 Author Posted January 19, 2013 ahaaaaa, understand, thank you very much
retaly Posted January 20, 2013 Author Posted January 20, 2013 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?
Moderators Melba23 Posted January 20, 2013 Moderators Posted January 20, 2013 retaly, I have absolutely no idea what you are asking - please explain in more detail! 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
retaly Posted January 20, 2013 Author Posted January 20, 2013 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? 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???
Moderators Melba23 Posted January 20, 2013 Moderators Posted January 20, 2013 retaly, Clear as mud! Do you mean something like this: 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 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
retaly Posted January 20, 2013 Author Posted January 20, 2013 yes, almost. i know, its hard to find out what i want without source 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
Moderators Melba23 Posted January 20, 2013 Moderators Posted January 20, 2013 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 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
retaly Posted January 20, 2013 Author Posted January 20, 2013 (edited) 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 January 20, 2013 by retaly
Moderators Melba23 Posted January 20, 2013 Moderators Posted January 20, 2013 retaly, I split this completely unrelated question into a new thread. 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