retaly Posted January 20, 2013 Share Posted January 20, 2013 possible to put right click menu with delete option for combo box items? this is the combo: $load = GUICtrlCreateCombo("", 112, 120, 185, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetOnEvent(-1, "_load") and this is the combo's load function, what's read datas from saved .ini file how can i do it?, right click to one item of combobox -> then delete option -> then delete it from .ini file... it will be an useful option.. :/ 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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 20, 2013 Moderators Share Posted January 20, 2013 retaly, When you have a completely new question, just open a new thread rather than attach it to the end of your last one. 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 Link to comment Share on other sites More sharing options...
guinness Posted January 20, 2013 Share Posted January 20, 2013 As you provided limited code I went ahead and created an example using GUIGetMsg. #include <Constants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> Example() Func Example() Local $hGUI = GUICreate('') Local $iComboBox = GUICtrlCreateCombo('Item1', 10, 10, Default, Default, $CBS_DROPDOWNLIST) GUICtrlSetData($iComboBox, 'Item2|Item3', 'Item3') Local $iContextMenu = GUICtrlCreateContextMenu($iComboBox) Local $iDelete = GUICtrlCreateMenuItem('Delete', $iContextMenu) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $iDelete ; Delete MsgBox($MB_SYSTEMMODAL, '', GUICtrlRead($iComboBox)) EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
guinness Posted January 20, 2013 Share Posted January 20, 2013 Oh and the delete part can be something like this >> IniDelete(@ScriptDir & '\IniFile.ini', 'Section', GUICtrlRead($iComboBox)) UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
retaly Posted January 20, 2013 Author Share Posted January 20, 2013 this code is deleting sections, its ok, and how can i do how it delet from the combo list too, because now just refreshing the list when i restart the program, and when delet one file, it delet from the ini but the list in combo isnt refreshing. Func _delete() IniDelete("Test.ini", GUICtrlRead($load), Default) ;MsgBox(4096, "", $var[$i]) EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 20, 2013 Moderators Share Posted January 20, 2013 retaly, Use a function to read the sections into a list which you then load into the combo. All you need do then is to call that function to reload the combo when you have deleted one of the sections. 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 Link to comment Share on other sites More sharing options...
retaly Posted January 20, 2013 Author Share Posted January 20, 2013 k but if i reload the sections to combo list, the deleted section still stay on the list, and it just add the list again to the combo, right? or i understand badly. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 20, 2013 Moderators Share Posted January 20, 2013 (edited) retaly, this code is deleting sections, its ok, [...] it delet from the ini [...]You said that the code was deleting sections from the ini - so re-reading the ini will give you a new list to load into the combo. That will update the contents so that the deleted section is no longer shown. M23 Edit: expandcollapse popup#include <GUIConstantsEx.au3> #include <ComboConstants.au3> Example() Func Example() Local $hGUI = GUICreate("") Local $iComboBox = GUICtrlCreateCombo("Item1", 10, 10, Default, Default, $CBS_DROPDOWNLIST) Local $sCombo_List = _Read_Ini() GUICtrlSetData($iComboBox, $sCombo_List) Local $iContextMenu = GUICtrlCreateContextMenu($iComboBox) Local $iDelete = GUICtrlCreateMenuItem("Delete", $iContextMenu) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $iDelete ; Delete MsgBox(0, "", GUICtrlRead($iComboBox)) IniDelete(@ScriptDir & "\List.ini", "Section", GUICtrlRead($iComboBox)) $sCombo_List = _Read_Ini() GUICtrlSetData($iComboBox, $sCombo_List) EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example Func _Read_Ini() Local $aSections = IniReadSection(@ScriptDir & "\List.ini", "Section") Local $sSection_List = "" For $i = 1 To $aSections[0][0] $sSection_List &= "|" & $aSections[$i][0] Next Return $sSection_List EndFunc List.ini [Section] Item 1=1 Item 2=1 Item 3=1 Have fun! Edited January 20, 2013 by Melba23 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 Link to comment Share on other sites More sharing options...
retaly Posted January 21, 2013 Author Share Posted January 21, 2013 i get error... -.- im stupid.. for combobox expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ComboConstants.au3> #include <Constants.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <FTP_Ex.au3> #include <GuiStatusBar.au3> Opt("GUIOnEventMode", 1) Local $var = IniReadSectionNames(@ScriptDir & "\Test.ini") Local $sCombo_List = _Read_Ini() 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 $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem2 = GUICtrlCreateMenu("Language", $MenuItem1) $MenuItem4 = GUICtrlCreateMenuItem("English", $MenuItem2) $MenuItem5 = GUICtrlCreateMenuItem("Hungary", $MenuItem2) $MenuItem3 = GUICtrlCreateMenuItem("Log", $MenuItem1) $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) $load = GUICtrlCreateCombo('', 120, 120, 185, 25, $CBS_DROPDOWNLIST) GUICtrlSetData($load, $sCombo_List) ;GUICtrlSetOnEvent(-1, "_load") $iContextMenu = GUICtrlCreateContextMenu($load) $iDelete = GUICtrlCreateMenuItem('Delete', $iContextMenu) GUICtrlSetOnEvent($iDelete, "_delete") $Connect = GUICtrlCreateButton("Connect", 168, 152, 131, 25) GUICtrlSetOnEvent(-1, "_connect") $line = GUICtrlCreateLabel("___________________________________________________", 32, 192, 266, 2, $SS_ETCHEDHORZ) $button_save = GUICtrlCreateButton("Save Server", 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) If FileExists("Test.ini") Then For $i = 1 To $var[0] ;MsgBox(4096, "", $var[$i]) GUICtrlSetData($load, $var[$i]) Next Else IniWrite("Test.ini", "", "", "") EndIf While Sleep(1000) WEnd Func _delete() IniDelete(@ScriptDir & "\Test.ini", GUICtrlRead($load), Default) $sCombo_List = _Read_Ini() GUICtrlSetData($load, $sCombo_List) ;IniDelete("Test.ini", GUICtrlRead($load), Default) ;MsgBox(4096, "", $var[$i]) EndFunc Func _Read_Ini() Local $aSections = IniReadSectionNames(@ScriptDir & "\Test.ini") Local $sSection_List = "" For $i = 1 To $aSections[0][0] $sSection_List &= "|" & $aSections[$i][0] Next Return $sSection_List 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) GUICtrlSetState($load, $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) GUICtrlSetState($load, $GUI_ENABLE) EndIf Else MsgBox(48, "Home FTP-Uploader", "Could not connected to the server!") EndIf _FTPClose($Open) EndFunc Func _savesettings() ; Ask for a host name $addname = InputBox("Save", "Please enter a host name!") ; 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 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 Func _Exit() Exit EndFunc ;==>_Exit Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 21, 2013 Moderators Share Posted January 21, 2013 retaly,You are using IniReadSectionNames to get the items for your combo list - this returns a 1D array according to the Help file. Yet you are using 2D array syntax to read it:For $i = 1 To $aSections[0][0] $sSection_List &= "|" & $aSections[$i][0] NextI used that syntax in my example because I was using IniReadSection on my ini file - which returns a 2D array. So adjust the array syntax in that loop and it should work correctly for you. 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 Link to comment Share on other sites More sharing options...
retaly Posted February 8, 2013 Author Share Posted February 8, 2013 hi dear, i tryed to do it in my script but cant .. :@ :S this is my script w/o ur script, i couldnt do it.. lease help, when delete is working, then reload option didnt reload expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ComboConstants.au3> #include <Constants.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <FTP_Ex.au3> #include <GuiStatusBar.au3> Opt("GUIOnEventMode", 1) Local $var = IniReadSectionNames(@ScriptDir & "\config.ini") Local $fRun = False Global $aControlID[4] Global $sIniFile = @ScriptDir & "\config.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 $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem2 = GUICtrlCreateMenu("Language", $MenuItem1) $MenuItem4 = GUICtrlCreateMenuItem("English", $MenuItem2) $MenuItem5 = GUICtrlCreateMenuItem("Hungary", $MenuItem2) $MenuItem3 = GUICtrlCreateMenuItem("Log", $MenuItem1) $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) $load = GUICtrlCreateCombo('', 120, 120, 185, 25, $CBS_DROPDOWNLIST) Local $sCombo_List = _Read_Ini() GUICtrlSetData($load, $sCombo_List) Local $iContextMenu = GUICtrlCreateContextMenu($load) Local $iDelete = GUICtrlCreateMenuItem("Delete", $iContextMenu) GUICtrlSetOnEvent(-1, "_delete_item") ;GUICtrlSetOnEvent($load, "_load") $iContextMenu = GUICtrlCreateContextMenu($load) $iDelete = GUICtrlCreateMenuItem('Delete', $iContextMenu) GUICtrlSetOnEvent($iDelete, "_delete") $Connect = GUICtrlCreateButton("Connect", 168, 152, 131, 25) GUICtrlSetOnEvent(-1, "_connect") $line = GUICtrlCreateLabel("___________________________________________________", 32, 192, 266, 2, $SS_ETCHEDHORZ) $button_save = GUICtrlCreateButton("Save Server", 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) Func _delete_item() MsgBox(0, "", GUICtrlRead($load)) IniDelete(@ScriptDir & "\config.ini", "Section", GUICtrlRead($load)) $sCombo_List = _Read_Ini() GUICtrlSetData($load, $sCombo_List) EndFunc Func _Read_Ini() If FileExists("config.ini") Then ;Local $var = IniReadSectionNames(@ScriptDir & "\config.ini") Local $sSection_List = "" GUICtrlSetData($load, $var) Return $sSection_List Else IniWrite("config.ini", "", "", "") EndIf EndFunc While Sleep(1000) WEnd Func _delete() IniDelete("Test.ini", GUICtrlRead($load), Default) ;MsgBox(4096, "", $var[$i]) 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) GUICtrlSetState($load, $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) GUICtrlSetState($load, $GUI_ENABLE) EndIf Else MsgBox(48, "Home FTP-Uploader", "Could not connected to the server!") EndIf _FTPClose($Open) EndFunc Func _savesettings() ; Ask for a host name $addname = InputBox("Save", "Please enter a host name!") ; 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 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 Func _Exit() Exit EndFunc ;==>_Exit Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2013 Moderators Share Posted February 8, 2013 retaly, Using this ini: [Item 1] [Item 2] [Item 4] [Item 5] the "delete" in this version of your script works for me: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ComboConstants.au3> #include <Constants.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <FTP_Ex.au3> #include <GuiStatusBar.au3> Opt("GUIOnEventMode", 1) Local $var = IniReadSectionNames(@ScriptDir & "\config.ini") Local $fRun = False Global $aControlID[4] Global $sIniFile = @ScriptDir & "\config.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 $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem2 = GUICtrlCreateMenu("Language", $MenuItem1) $MenuItem4 = GUICtrlCreateMenuItem("English", $MenuItem2) $MenuItem5 = GUICtrlCreateMenuItem("Hungary", $MenuItem2) $MenuItem3 = GUICtrlCreateMenuItem("Log", $MenuItem1) $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) $load = GUICtrlCreateCombo('', 120, 120, 185, 25, $CBS_DROPDOWNLIST) _Load_Combo() Local $iContextMenu = GUICtrlCreateContextMenu($load) Local $iDelete = GUICtrlCreateMenuItem("Delete", $iContextMenu) GUICtrlSetOnEvent(-1, "_delete_item") $Connect = GUICtrlCreateButton("Connect", 168, 152, 131, 25) GUICtrlSetOnEvent(-1, "_connect") $line = GUICtrlCreateLabel("___________________________________________________", 32, 192, 266, 2, $SS_ETCHEDHORZ) $button_save = GUICtrlCreateButton("Save Server", 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) While Sleep(1000) WEnd Func _delete_item() MsgBox(0, "", GUICtrlRead($load)) IniDelete($sIniFile, GUICtrlRead($load), Default) _Load_Combo() EndFunc ;==>_delete_item Func _Load_Combo() If FileExists($sIniFile) Then Local $aSections = IniReadSectionNames($sIniFile) Local $sSection_List = "" For $i = 1 To $aSections[0] $sSection_List &= "|" & $aSections[$i] Next GUICtrlSetData($load, $sSection_List) Else IniWrite($sIniFile, "", "", "") EndIf EndFunc ;==>_Load_Combo 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) GUICtrlSetState($load, $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) GUICtrlSetState($load, $GUI_ENABLE) EndIf Else MsgBox(48, "Home FTP-Uploader", "Could not connected to the server!") EndIf _FTPClose($Open) EndFunc ;==>_connect Func _savesettings() ; Ask for a host name $addname = InputBox("Save", "Please enter a host name!") ; 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 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 ;==>_load Func _Exit() Exit EndFunc ;==>_Exit 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 Link to comment Share on other sites More sharing options...
retaly Posted February 8, 2013 Author Share Posted February 8, 2013 k but the problem, need to save datas below section names, because now oke, its working (delet, add option) but there aren't hostn/usern/passw options for section names when load a section, Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2013 Moderators Share Posted February 8, 2013 retaly, After recovering from the shock of the effusive thanks that you felt it necessary to offer for my last effort, I seem to understand now that you want to load host/user/pass values from a section when it is loaded - and presumably save them when you add a new host section to the ini. If that is the case then this should work: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ComboConstants.au3> #include <Constants.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <FTP_Ex.au3> #include <GuiStatusBar.au3> Opt("GUIOnEventMode", 1) Local $var = IniReadSectionNames(@ScriptDir & "\config.ini") Local $fRun = False Global $aControlID[4] Global $sIniFile = @ScriptDir & "\config.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 $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem2 = GUICtrlCreateMenu("Language", $MenuItem1) $MenuItem4 = GUICtrlCreateMenuItem("English", $MenuItem2) $MenuItem5 = GUICtrlCreateMenuItem("Hungary", $MenuItem2) $MenuItem3 = GUICtrlCreateMenuItem("Log", $MenuItem1) $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) $load = GUICtrlCreateCombo('', 120, 120, 185, 25, $CBS_DROPDOWNLIST) GUICtrlSetOnEvent(-1, "_load") _Load_Combo() Local $iContextMenu = GUICtrlCreateContextMenu($load) Local $iDelete = GUICtrlCreateMenuItem("Delete", $iContextMenu) GUICtrlSetOnEvent(-1, "_delete_item") $Connect = GUICtrlCreateButton("Connect", 168, 152, 131, 25) GUICtrlSetOnEvent(-1, "_connect") $line = GUICtrlCreateLabel("___________________________________________________", 32, 192, 266, 2, $SS_ETCHEDHORZ) $button_save = GUICtrlCreateButton("Save Server", 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) While Sleep(1000) WEnd Func _delete_item() MsgBox(0, "", GUICtrlRead($load)) IniDelete($sIniFile, GUICtrlRead($load), Default) _Load_Combo() GUICtrlSetData($aControlID[0], "") GUICtrlSetData($aControlID[1], "") GUICtrlSetData($aControlID[2], "") GUICtrlSetState($aControlID[3], $GUI_UNCHECKED) EndFunc ;==>_delete_item Func _Load_Combo($sDefault = "") If FileExists($sIniFile) Then Local $aSections = IniReadSectionNames($sIniFile) Local $sSection_List = "" For $i = 1 To $aSections[0] $sSection_List &= "|" & $aSections[$i] Next If $sDefault Then GUICtrlSetData($load, $sSection_List, $sDefault) Else GUICtrlSetData($load, $sSection_List) EndIf Else IniWrite($sIniFile, "", "", "") EndIf EndFunc ;==>_Load_Combo 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) GUICtrlSetState($load, $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) GUICtrlSetState($load, $GUI_ENABLE) EndIf Else MsgBox(48, "Home FTP-Uploader", "Could not connected to the server!") EndIf _FTPClose($Open) EndFunc ;==>_connect Func _savesettings() ; Ask for a host name $addname = InputBox("Save", "Please enter a host name!") ; 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 IniWrite($sIniFile, $addname, "host", GUICtrlRead($aControlID[0])) IniWrite($sIniFile, $addname, "user", GUICtrlRead($aControlID[1])) IniWrite($sIniFile, $addname, "pass", GUICtrlRead($aControlID[2])) If GUICtrlRead($aControlID[3]) = 1 Then IniWrite($sIniFile, $addname, "link", 1) Else IniWrite($sIniFile, $addname, "link", 0) EndIf _Load_Combo($addname) ; Return no error and the name that was entered Return SetError(0, 0, $addname) EndSwitch EndFunc ;==>_savesettings Func _load() $sSection = GUICtrlRead($load) GUICtrlSetData($aControlID[0], IniRead($sIniFile, $sSection, "host", "Error")) GUICtrlSetData($aControlID[1], IniRead($sIniFile, $sSection, "user", "Error")) GUICtrlSetData($aControlID[2], IniRead($sIniFile, $sSection, "pass", "Error")) GUICtrlSetState($aControlID[3], $GUI_UNCHECKED) If IniRead($sIniFile, $sSection, "link", "0") = 1 Then GUICtrlSetState($aControlID[3], $GUI_CHECKED) EndIf EndFunc ;==>_load Func _Exit() Exit EndFunc ;==>_Exit and the ini: [Item 1] host=host1 user=user1 pass=pass1 link=1 [Item 2] host=host2 user=user2 pass=pass2 link=0 [Item 3] host=host3 user=user3 pass=pass3 link=1 [Item 4] host=host4 user=user4 pass=pass4 link=0 [Item 5] host=host5 user=user5 pass=pass5 link=1 Does sir have any other requests while I am around? 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 Link to comment Share on other sites More sharing options...
retaly Posted February 8, 2013 Author Share Posted February 8, 2013 tytytytytytytytytytytyttyy u are the BOSSSSSSSSSSSSSSSSSSSSSS i wanted that, exactly that! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2013 Moderators Share Posted February 8, 2013 retaly, Glad we got there. 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 Link to comment Share on other sites More sharing options...
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