|
楼主 |
发表于 2016-6-13 17:08:36
|
显示全部楼层
回复 22# kk_lee69
大哥, 別生氣, 快搞定了, 你剛剛給我的code是我想要的, 只是被我改一改, 第268行有error, 可以幫我看一下嗎, 謝謝妳拉~~#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>
;Local $GUI, $hImage, $iITEM_COUNT = 10000
GUICreate("Test Management v1.0", 1060, 410)
$hListView = GUICtrlCreateListView("", 5, 5, 1050, 345, $LVS_SHOWSELALWAYS, $LVS_EX_GRIDLINES + $LVS_EX_FULLROWSELECT + $LVS_EX_DOUBLEBUFFER)
;===================================================================
$Button1 = GUICtrlCreateButton("ReportData", 200, 362, 73, 33)
$Button2 = GUICtrlCreateButton("Complete", 300, 362, 73, 33)
$Button3 = GUICtrlCreateButton("Clear", 800, 362, 73, 33)
$PowerReset = GUICtrlCreateButton("Power Reset", 500, 362, 73, 33)
$SerialOverLan = GUICtrlCreateButton("SOL", 600, 362, 73, 33)
;$stopreportflash = GUICtrlCreateButton("Stopreportflash", 200, 392, 73, 33)
;$stopcompleteflash = GUICtrlCreateButton("Stopcompleteflash", 300, 392, 73, 33)
;===================================================================
GUISetState()
;GUISetState(@SW_SHOW)
_GUICtrlListView_AddColumn($hListView, "File Name", 0) ;disappear file name
_GUICtrlListView_AddColumn($hListView, "Test Case", 70)
_GUICtrlListView_AddColumn($hListView, "Product", 80)
_GUICtrlListView_AddColumn($hListView, "Serial", 90)
_GUICtrlListView_AddColumn($hListView, "BIOS", 40)
_GUICtrlListView_AddColumn($hListView, "BMC", 40)
_GUICtrlListView_AddColumn($hListView, "Count", 60)
_GUICtrlListView_AddColumn($hListView, "Status", 60)
_GUICtrlListView_AddColumn($hListView, "LOG err", 50)
_GUICtrlListView_AddColumn($hListView, "BMC err", 50)
_GUICtrlListView_AddColumn($hListView, "SDR err", 50)
_GUICtrlListView_AddColumn($hListView, "Sensor err", 65)
_GUICtrlListView_AddColumn($hListView, "BMC IP", 90)
_GUICtrlListView_AddColumn($hListView, "Tester", 50)
_GUICtrlListView_AddColumn($hListView, "Remind Time", 80)
_GUICtrlListView_AddColumn($hListView, "Upload Time", 120)
_GUICtrlListView_SetItemCount($hListView, 5000)
DIM $OldList="" , $NEWList=""
While 1
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;Double click value get
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Button1
AdlibUnRegister('_add_complete_items')
_add_report_items()
AdlibRegister('_add_report_items', 5000);reflash every 10sec
AdlibRegister('_Checkitems', 10000); 10秒 檢查
_Checkitems()
Case $Button2
AdlibUnRegister('_add_report_items')
_add_complete_items()
AdlibRegister('_add_complete_items', 5000);reflash every 10sec
; Case $stopreportflash
; AdlibUnRegister('_add_report_items')
; Case $stopcompleteflash
; AdlibUnRegister('_add_complete_items')
Case $Button3
MsgBox(0,"123","456",0)
Case $PowerReset
Run("PowerReset.exe")
Case $SerialOverLan
Run("SOL.exe")
EndSwitch
WEnd
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Exit
Func _add_report_items()
;_GUICtrlListView_SetHoverTime($hListView,6000)
;MsgBox($MB_SYSTEMMODAL, "Information", "Hover Time (milliseconds): " & _GUICtrlListView_GetHoverTime($hListView))
FileChangeDir("\\192.8.1.1\fs1\1")
Local $path, $aFileList, $aNewList[1][2]
$path = "\\192.8.1.1\fs1\1"
$aFileList = _FileListToArray($path, "*.txt")
If IsArray($aFileList) Then
ReDim $aNewList[UBound($aFileList)][16] ;;;[Col count]
For $i = 0 To UBound($aFileList) - 1 Step 1
$aNewList[0][1] = $i
;$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)
$aNewList[$i][5] = FileReadLine($aFileList[$i], 5)
$aNewList[$i][6] = FileReadLine($aFileList[$i], 6)
$aNewList[$i][7] = FileReadLine($aFileList[$i], 7)
$aNewList[$i][8] = FileReadLine($aFileList[$i], 8)
$aNewList[$i][9] = FileReadLine($aFileList[$i], 9)
$aNewList[$i][10] = FileReadLine($aFileList[$i], 10)
$aNewList[$i][11] = FileReadLine($aFileList[$i], 11)
$aNewList[$i][12] = FileReadLine($aFileList[$i], 12)
$aNewList[$i][13] = FileReadLine($aFileList[$i], 13)
$aNewList[$i][14] = FileReadLine($aFileList[$i], 14)
$aNewList[$i][15] = FileReadLine($aFileList[$i], 15)
;$change1=FileReadLine($aFileList[$i], 1)
Next
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView))
_GUICtrlListView_AddArray($hListView, $aNewList)
EndIf
EndFunc
Func _add_complete_items()
FileChangeDir("\\192.8.1.1\fs1\2")
Local $path, $aFileList, $aNewList[1][2]
$path = "\\192.8.1.1\fs1\2"
$aFileList = _FileListToArray($path, "*.txt")
If IsArray($aFileList) Then
ReDim $aNewList[UBound($aFileList)][16] ;;;[Col count]
For $i = 0 To UBound($aFileList) - 1 Step 1
$aNewList[0][1] = $i
;$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)
$aNewList[$i][5] = FileReadLine($aFileList[$i], 5)
$aNewList[$i][6] = FileReadLine($aFileList[$i], 6)
$aNewList[$i][7] = FileReadLine($aFileList[$i], 7)
$aNewList[$i][8] = FileReadLine($aFileList[$i], 8)
$aNewList[$i][9] = FileReadLine($aFileList[$i], 9)
$aNewList[$i][10] = FileReadLine($aFileList[$i], 10)
$aNewList[$i][11] = FileReadLine($aFileList[$i], 11)
$aNewList[$i][12] = FileReadLine($aFileList[$i], 12)
$aNewList[$i][13] = FileReadLine($aFileList[$i], 13)
$aNewList[$i][14] = FileReadLine($aFileList[$i], 14)
$aNewList[$i][15] = FileReadLine($aFileList[$i], 15)
Next
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView))
_GUICtrlListView_AddArray($hListView, $aNewList)
EndIf
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = GUICtrlGetHandle($hListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
$Index = GUICtrlRead($hListView)
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_DBLCLK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$Index = DllStructGetData($tInfo, "Index")
$DoubleClick = _GUICtrlListView_GetItemText($hListView, $Index,12)
;MsgBox(0, 'Connect SOL to BMC IP', _GUICtrlListView_GetItemText($hListView, $Index,12))
Run("cmd.exe")
sleep(500)
WinActivate("Administrator: C:\Windows\system32\cmd.exe")
sleep(500)
send("cd \TestStatusManagement\ipmitool_1.8.11")
sleep(500)
Send("{ENTER}")
sleep(500)
Send("ipmitool.exe -I lanplus -H "&$DoubleClick&" -U admin -P admin sol deactivate")
sleep(500)
Send("{ENTER}")
sleep(500)
Send("ipmitool.exe -I lanplus -H "&$DoubleClick&" -U admin -P admin sol activate")
sleep(500)
Send("{ENTER}")
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
$tNMHDR = 0
EndFunc
Func _Checkitems()
Local $path, $aFileList, $aNewList2[1][2]
$path = @ScriptDir
$aFileList = _FileListToArray($path, "*.txt")
_ArrayDelete($aFileList,0)
If IsArray($aFileList) Then
ReDim $aNewList2[UBound($aFileList)][16] ;;;[Col count]
For $i = 0 To UBound($aFileList) - 1 Step 1
$aNewList2[$i][0] = $aFileList[$i]
$aNewList2[$i][1] = FileReadLine($aFileList[$i], 1)
$aNewList2[$i][2] = FileReadLine($aFileList[$i], 2)
$aNewList2[$i][3] = FileReadLine($aFileList[$i], 3)
$aNewList2[$i][4] = FileReadLine($aFileList[$i], 4)
$aNewList2[$i][5] = FileReadLine($aFileList[$i], 5)
$aNewList2[$i][6] = FileReadLine($aFileList[$i], 6)
$aNewList2[$i][7] = FileReadLine($aFileList[$i], 7)
$aNewList2[$i][8] = FileReadLine($aFileList[$i], 8)
$aNewList2[$i][9] = FileReadLine($aFileList[$i], 9)
$aNewList2[$i][10] = FileReadLine($aFileList[$i], 10)
$aNewList2[$i][11] = FileReadLine($aFileList[$i], 11)
$aNewList2[$i][12] = FileReadLine($aFileList[$i], 12)
$aNewList2[$i][13] = FileReadLine($aFileList[$i], 13)
$aNewList2[$i][14] = FileReadLine($aFileList[$i], 14)
$aNewList2[$i][15] = FileReadLine($aFileList[$i], 15)
Next
; _ArrayDisplay($aNewList2)
EndIf
If IsArray($OldList) Then
For $j=0 TO UBound($OldList)-1 STEP 1
IF $OldList[$j][4]= $aNewList2[$j][4] Then
_GUICtrlListView_SetItemText($hListView,$Index,"Off-line",7)
Else
_GUICtrlListView_SetItemText($hListView,$Index,"On-line",7)
EndIf
Next
$OldList=$aNewList2
Else
$OldList=$aNewList2
EndIf
EndFunc
|
|