回复 11# ipmitool
运行:
点击"Filter":
输入框查询,点击"搜索All":
点击"返回":
代码:
#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>
#include <FileConstants.au3>
#include <Date.au3>
#include <GuiStatusBar.au3>
Local $path, $aFileList, $aNewList[1][2]
$path = @ScriptDir
$aFileList = _FileListToArray($path, "*.txt")
Local $iI, $iTimer, $hListView
GUICreate("Test Management v1.0", 800, 300)
$hListView = GUICtrlCreateListView("", 15, 15, 550, 268)
$cInput_Filter = GUICtrlCreateInput("", 600, 90, 155, 20)
$cButton_Filter = GUICtrlCreateButton("Filter", 600, 146, 75, 23)
$cButton_All = GUICtrlCreateButton("搜索All", 600, 118, 155, 23)
$cButton_du = GUICtrlCreateButton("返回", 680, 146, 75, 23)
GUISetState(@SW_SHOW)
_GUICtrlListView_AddColumn($hListView, "Tester", 100)
_GUICtrlListView_AddColumn($hListView, "Test Item", 100)
_GUICtrlListView_AddColumn($hListView, "Count > 500", 100)
_GUICtrlListView_AddColumn($hListView, "Count", 60)
_GUICtrlListView_AddColumn($hListView, "Last Record Time", 150)
If IsArray($aFileList) Then
ReDim $aNewList[UBound($aFileList)][5]
; Local $sComboTxt = "所有"
For $i = 1 To UBound($aFileList) - 1 Step 1
$aNewList[$i][0] = $aFileList[$i]
$aNewList[$i][1] = FileReadLine($aFileList[$i], 1)
$aNewList[$i][2] = FileReadLine($aFileList[$i], 2)
$aNewList[$i][3] = FileReadLine($aFileList[$i], 3)
$aNewList[$i][4] = FileReadLine($aFileList[$i], 4)
$h8 = "Yes"
If $aNewList[$i][3] >= 500 Then
GUICtrlCreateListViewItem($aNewList[$i][0] & "|" & $aNewList[$i][1] & "|" & $h8 & "|" & $aNewList[$i][3] & "|" & $aNewList[$i][4], $hListView)
Else
GUICtrlCreateListViewItem($aNewList[$i][0] & "|" & $aNewList[$i][1] & "|" & $aNewList[$i][2] & "|" & $aNewList[$i][3] & "|" & $aNewList[$i][4], $hListView)
EndIf
; If Not StringInStr($sComboTxt, $aNewList[$i][1]) Then $sComboTxt &= "|" & $aNewList[$i][1]
Next
;_GUICtrlListView_AddArray($hListView, $aNewList)
EndIf
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $cButton_Filter
_FilterItem(GUICtrlRead($cInput_Filter))
Case $cButton_All
_ShowAll()
Case $cButton_du
_Showdu()
EndSwitch
WEnd
Func _Showdu()
GUICtrlSetData($cInput_Filter, "")
GUICtrlSendMsg($hListView, $LVM_DELETEALLITEMS, 0, 0)
If IsArray($aFileList) Then
ReDim $aNewList[UBound($aFileList)][5]
; Local $sComboTxt = "所有"
For $i = 1 To UBound($aFileList) - 1 Step 1
$aNewList[$i][0] = $aFileList[$i]
$aNewList[$i][1] = FileReadLine($aFileList[$i], 1)
$aNewList[$i][2] = FileReadLine($aFileList[$i], 2)
$aNewList[$i][3] = FileReadLine($aFileList[$i], 3)
$aNewList[$i][4] = FileReadLine($aFileList[$i], 4)
$h8 = "Yes"
If $aNewList[$i][3] >= 500 Then
GUICtrlCreateListViewItem($aNewList[$i][0] & "|" & $aNewList[$i][1] & "|" & $h8 & "|" & $aNewList[$i][3] & "|" & $aNewList[$i][4], $hListView)
Else
GUICtrlCreateListViewItem($aNewList[$i][0] & "|" & $aNewList[$i][1] & "|" & $aNewList[$i][2] & "|" & $aNewList[$i][3] & "|" & $aNewList[$i][4], $hListView)
EndIf
Next
EndIf
EndFunc ;==>_Showdu
Func _ShowAll()
$cInput = GUICtrlRead($cInput_Filter)
GUICtrlSendMsg($hListView, $LVM_DELETEALLITEMS, 0, 0)
For $i = 0 To UBound($aNewList) - 1
$h8 = "Yes"
If $aNewList[$i][1] = $cInput Then
If $aNewList[$i][3] >= 500 Then
GUICtrlCreateListViewItem($aNewList[$i][0] & "|" & $aNewList[$i][1] & "|" & $h8 & "|" & $aNewList[$i][3] & "|" & $aNewList[$i][4], $hListView)
Else
GUICtrlCreateListViewItem($aNewList[$i][0] & "|" & $aNewList[$i][1] & "|" & $aNewList[$i][2] & "|" & $aNewList[$i][3] & "|" & $aNewList[$i][4], $hListView)
EndIf
EndIf
Next
EndFunc ;==>_ShowAll
Func _FilterItem($sText)
GUICtrlSetData($cInput_Filter, "")
GUICtrlSendMsg($hListView, $LVM_DELETEALLITEMS, 0, 0)
For $i = 0 To UBound($aNewList) - 1
$h8 = "Yes"
If $aNewList[$i][3] >= 500 Then
GUICtrlCreateListViewItem($aNewList[$i][0] & "|" & $aNewList[$i][1] & "|" & $h8 & "|" & $aNewList[$i][3] & "|" & $aNewList[$i][4], $hListView)
Else
EndIf
Next
EndFunc ;==>_FilterItem
|