soebis Posted May 3, 2012 Posted May 3, 2012 hi sorry I'm not good english I have a problem delete all items in the combobox This script I expandcollapse popup#NoTrayIcon #RequireAdmin #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <String.au3> #include <Array.au3> #include <GUIComboBox.au3> #include <File.au3> #include <GUIEdit.au3> #Region ### START Koda GUI section ### Form=e:\kumpulan script\koda_1.7.3.0\forms\dialup.kxf $Form2 = GUICreate("Percobaan", 488, 211, 181, 137) $Group1 = GUICtrlCreateGroup("Dial Up", 16, 16, 289, 113) $cmb_dial = GUICtrlCreateCombo("", 32, 52, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $Label1 = GUICtrlCreateLabel("Dial Up Name", 32, 35, 70, 17) $update = GUICtrlCreateButton("Update", 216, 50, 73, 25, $WS_BORDER) $input_ipc = GUICtrlCreateInput("", 32, 96, 145, 21) $Label2 = GUICtrlCreateLabel("Hunter IPC", 32, 80, 56, 17) $btn_connect= GUICtrlCreateButton("Connect", 184, 94, 105, 25, $WS_BORDER) $clear = GUICtrlCreateButton("C", 184, 50, 25, 25, $WS_BORDER) GUICtrlSetTip(-1, "Clear All Dial Up Profil") GUICtrlCreateGroup("", -99, -99, 1, 1) $lsbox_ipc = GUICtrlCreateList("", 314, 22, 153, 162) $Group2 = GUICtrlCreateGroup("IPC Kamu Sekarang", 16, 136, 289, 49) $lbl_status = GUICtrlCreateEdit("", 48, 155, 217, 20, BitOR($ES_CENTER,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN)) GUICtrlSetData(-1, "") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) _LoadSetting() #EndRegion ### END Koda GUI section ### #region func _update() Run("rasphone.exe") WinWait("Network Connections") $hnd = ControlGetHandle("Network Connections", "", "ComboBox1") $lis_arr = _guictrlcombobox_getlistarray($hnd) For $i = 1 To $lis_arr[0] Step 1 _GUICtrlComboBox_AddString($cmb_dial,$lis_arr[$i]) Next WinClose("Network Connection") EndFunc #endregion #region Func clear() _GUICtrlComboBox_deleteallitems($cmb_dial, 1) EndFunc #Endregion #region $setting = @ScriptDir&"\my_setting.ini" $configuration = "Configuration" $last_dialname = "Last DialName" $last_dial = "Last Dial" $last_ipc = "Last IPC" If Not FileExists($setting) Then _FileCreate($setting) FileSetAttrib($setting, "H") IniWriteSection($setting,$configuration,"") IniWrite($setting,$configuration,$last_dialname,"") IniWrite($setting,$configuration,$last_dial,"") IniWrite($setting,$configuration,$last_ipc,"") EndIf Func _SaveSetting() IniWrite($setting, $configuration, $last_dialname, _guictrlcombobox_getlist($cmb_dial)) IniWrite($setting, $configuration, $last_dial, Guictrlread($cmb_dial)) IniWrite($setting, $configuration, $last_ipc,GUICtrlRead($input_ipc)) EndFunc Func _LoadSetting() $d_arr = StringSplit(IniRead("my_setting.ini", "configuration", "Last DialName", ""), "|") For $i = 1 To $d_arr[0] Step 1 _guictrlcombobox_addstring($cmb_dial, $d_arr[$i]) Next _guictrlcombobox_selectstring($cmb_dial, IniRead("my_setting.ini", "Configuration", "Last Dial", "")) GUICtrlSetData($input_ipc, IniRead("my_setting.ini", "Configuration", "Last IPC", "")) EndFunc #endregion #region Global $status = "",$disconnected = "Disconnected",$connected = "Connected" If @IPAddress1 <> "127.0.0.1" Then $status = $connected GUICtrlSetData($btn_connect,"Disconnect") Else $status = $disconnected EndIf Func _UpdateStatus($status_text) GUICtrlSetData($lbl_status,"") _GUICtrlEdit_AppendText(@CRLF & $lbl_status,$status_text) EndFunc #endregion #Region Func real_search() While ip_search() = 0 _disconnect() _connect() _guictrllistbox_addstring($input_ipc, @IPAddress1) GUICtrlSetData($lsbox_ipc,@IPAddress1) WEnd If ip_search() = 1 Then _disconnect() _connect() _guictrllistbox_addstring($input_ipc, @IPAddress1) GUICtrlSetData($lsbox_ipc,@IPAddress1) EndIf EndFunc #Endregion #region Func ip_search() $ip_string = GUictrlread($input_ipc) Switch $ip_string Case "" Return 1 Case Else $ip_stringsplit = StringSplit(Guictrlread($input_ipc), " ") For $i = 1 To $ip_stringsplit[0] Step 1 If StringInStr(@IPAddress1, $ip_stringsplit[$i]) = 1 Then Return 2 ExitLoop Else ContinueLoop EndIf Next Return 0 EndSwitch EndFunc #endregion #region func _connect() $dial_name = GUICtrlRead($cmb_dial) _UpdateStatus("Connecting to "& $dial_name) $connect_process = Run("rasdial "&$dial_name,"",@SW_HIDE) Sleep(100) ProcessWaitClose($connect_process) _UpdateStatus("Connected to " & $dial_name) GUICtrlSetData($lsbox_ipc,@IPAddress1) Sleep(100) _UpdateStatus("Connected IP " & @IPAddress1) $status = $connected GUICtrlSetData($btn_connect,"Disconnect") EndFunc #endregion #Region Func _Disconnect() _UpdateStatus("Disconnecting...") $dial_name = GUICtrlRead($cmb_dial) $disconnect_process = Run("rasdial "&$dial_name&" /disconnect","",@SW_HIDE) Sleep(100) ProcessWaitClose($disconnect_process) _UpdateStatus("Disconnected from " & $dial_name) Sleep(100) $status = $disconnected GUICtrlSetData($btn_connect,"Connect") EndFunc #endregion #Region While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _SaveSetting() Exit Case $btn_connect Switch $status Case $disconnected real_search() Case $connected _Disconnect() case $clear clear() EndSwitch case $update _update() EndSwitch WEnd #endregion how if at the click of a button clear all deleted items in the combobox please help me
BrewManNH Posted May 4, 2012 Posted May 4, 2012 It doesn't work because you're using a non-existing function (_GUICtrlComboBox_deleteallitems) this function doesn't exist.You should be using GUICtrlSetData to change the information in the combobox.From the help file:For Combo or List control :If the "data" corresponds to an already existing entry it is set as the default.If the "data" starts with GUIDataSeparatorChar or is an empty string "" the previous list is destroyed If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
soebis Posted May 4, 2012 Author Posted May 4, 2012 It doesn't work because you're using a non-existing function (_GUICtrlComboBox_deleteallitems) this function doesn't exist.You should be using GUICtrlSetData to change the information in the combobox.I have tried, but still can not work
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