VAADAdmin Posted February 16, 2007 Posted February 16, 2007 Let me try this again. I posted this once and now it is gone, so if I posted wrong I apologize. I have _GUICtrlListViewDeleteAllItems in this script in the dsquery function but it does not delete the items. I have used this in another script with no issues but cannot figure out why it will not delete in this script. expandcollapse popup#include <GUIConstants.au3> #Include <GuiTreeView.au3> #Include <GuiListView.au3> #Include <GuiList.au3> #include <date.au3> #include <Constants.au3> #include <File.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode #Region ### START Koda GUI section ### Form=C:\Documents and Settings\bsiegm\Desktop\Scripting\Koda\Forms\DSQuery.kxf $Form1 = GUICreate("DSQuery", 633, 533, 193, 115) $Go_btn = GUICtrlCreateButton("Go", 416, 16, 75, 25, 0) $domain_combo = GUICtrlCreateCombo("Domain", 64, 48, 145, 25) GUICtrlSetData(-1,"Root","Domain") $Label1 = GUICtrlCreateLabel("DSQuery", 8, 16, 47, 17) $domain_lbl = GUICtrlCreateLabel("Domain", 8, 48, 40, 17) $limit_lbl = GUICtrlCreateLabel("Limit", 8, 88, 25, 17) $limit_input = GUICtrlCreateInput("", 64, 80, 121, 21) $time_lbl = GUICtrlCreateLabel("Weeks", 8, 128, 38, 17) $time_input = GUICtrlCreateInput("", 64, 120, 121, 21) $results_listview = GUICtrlCreateListView("Computer DN", 40, 168, 546, 222) $select_all_btn = GUICtrlCreateButton("&Select All", 40, 400, 75, 25, 0) $clear_all_btn = GUICtrlCreateButton("&Clear All", 128, 400, 75, 25, 0) $save_as_btn = GUICtrlCreateButton("Save As...", 296, 400, 75, 25, 0) $help_btn = GUICtrlCreateButton("&Help", 528, 488, 75, 25, 0) $exit_btn = GUICtrlCreateButton("&Exit", 432, 488, 75, 25, 0) $attributes_btn = GUICtrlCreateButton("&Attributes",432,75) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetOnEvent($Go_btn,"_dsquery") GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") Dim $sArray While 1 Sleep(10) WEnd Func SpecialEvents() Select Case @GUI_CTRLID = $GUI_EVENT_CLOSE Exit Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE Case @GUI_CTRLID = $GUI_EVENT_RESTORE EndSelect EndFunc Func _dsquery() _GUICtrlListViewDeleteAllItems($results_listview) $dsquery_results = RunWait(@ComSpec & " /c dsquery computer domainroot -d " & GUICtrlRead($domain_combo) & _ " -limit "& GUICtrlRead($limit_input) & " -inactive "& GUICtrlRead($time_input) & " > " & _ '"C:\Documents and Settings\bsiegm\Desktop\Scripting\AutoIT Scripts\DSQuery\results.txt"') $file1 = FileOpen("results.txt", 0) ;Check if file opened for reading OK If $file1 = -1 Then MsgBox(0, " Error ", " Unable to open file1. ", 30) Exit EndIf $file2 = FileOpen("results2.txt", 2) While 1 $line1 = FileReadLine($file1) If @error = -1 Then ExitLoop ;delete trailing whitespace FileWriteLine($file2, StringStripWS($line1, 8)) WEnd FileClose($file2) FileClose($file1) Local $filePath = "results2.txt" Local $aArray = '' _FileReadToArray($filePath, $aArray) Local $sArray = _SeperateEachWord($aArray) For $x = 1 To UBound($sArray) - 1 $results = GUICtrlCreateListViewItem($sArray[$x],$results_listview) GUICtrlSetData($results,StringTrimRight(StringTrimLeft($sArray[$x],1),1)) Next EndFunc Func _SeperateEachWord(ByRef $aArray, $dDelimeter = ' ') For $i = 1 To Ubound($aArray) - 1 If $aArray[$i] <> '' Then $SplitSpace = StringSplit($aArray[$i], $dDelimeter) For $x = 1 To UBound($SplitSpace) - 1 $sArray = $sArray & $SplitSpace[$x] & Chr(01) Next EndIf Next Return StringSplit(StringTrimRight($sArray, 1), Chr(01)) EndFunc
Josbe Posted February 16, 2007 Posted February 16, 2007 That function works fine. You can prove this with a MsgBox after _GUICtrlListViewDeleteAllItems() for pause.The error looks in your function _SeperateEachWord() or handling the arrays, check it.I posted this once and now it is gone, so if I posted wrong I apologize.Don't worry, was something about the yesterday backup. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
VAADAdmin Posted February 16, 2007 Author Posted February 16, 2007 Thanks for the reply, I will continue looking.
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