ipmitool 发表于 2016-5-13 08:03:28

[已解決]請問如何讓 array 顯示在GUI裡面? 然後每秒更新一次array

本帖最后由 ipmitool 于 2016-5-13 18:58 编辑

請問如何讓 array 顯示在GUI裡面啊?
然後每秒刷新一次array...
拜託各位大大高手幫忙了, 謝謝!


1.txt
sdfasdfsadfasdadfasdfasdfasdfs!ER#$@sdfasdfsadfasdadfasdfasdfas

2.txt
sdfasdfsad@fasdadfasdfasdfasdfs!ER#$@sdfasdfsadfasdadfasdfasdfas
sdfasdfsadfasdadfasdfasdfasdfs!ER#$@sdfasdfsadfasdadfasdfasdfas

3.txt
sdfsdfsf@w32
dsfgsg@dvsfgds
advsfgfhnjt5
Sdsdfgdgdgh
dsfw43@wrgt35y45@jmryjr

4.txt
advfssfdfbg5324353@wr535t3y
ergergy43@243453
@Vadgwrgwg
VDsaf@gryjhr
#include <Array.au3>
#include <File.au3>
Local $path, $aFileList, $aNewList
$path = @ScriptDir
$aFileList = _FileListToArray($path, "*.txt")
If IsArray($aFileList) Then
      ReDim $aNewList
      For $i = 0 To UBound($aFileList) - 1 Step 1
                $aNewList[$i] = $aFileList[$i]
                $aNewList[$i] = FileRead($aFileList[$i])
      Next
      _ArrayDisplay($aNewList, "$aFileList")
EndIf

ipmitool 发表于 2016-5-13 15:01:10

大大們有沒有招啊...拜託幫幫忙~

131738 发表于 2016-5-13 15:43:30

循环写数组值到列表视图不行吗?........

ipmitool 发表于 2016-5-13 15:51:56

功力不夠...麻煩大大幫忙了...

ipmitool 发表于 2016-5-13 16:51:59

大大們,
我成功了,
只是要怎麼讓裡面的array每秒重新scan/reflash一次啊...#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Local $path, $aFileList, $aNewList
$path = @ScriptDir
$aFileList = _FileListToArray($path, "*.txt")



Local $iI, $iTimer, $idListview
GUICreate("ListView Add Array", 800, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)


        _GUICtrlListView_AddColumn($idListview, "Tester", 100)
    _GUICtrlListView_AddColumn($idListview, "Test Item", 100)
    _GUICtrlListView_AddColumn($idListview, "BMC IP", 100)
    _GUICtrlListView_AddColumn($idListview, "Count", 100)
    _GUICtrlListView_AddColumn($idListview, "Last Record Time", 100)

    _GUICtrlListView_SetItemCount($idListview, 5000)




If IsArray($aFileList) Then

      ReDim $aNewList   ;;;
      For $i = 0 To UBound($aFileList) - 1 Step 1
                $aNewList[$i] = $aFileList[$i]
                $aNewList[$i] = FileReadLine($aFileList[$i],1)
                                $aNewList[$i] = FileReadLine($aFileList[$i],2)
                                $aNewList[$i] = FileReadLine($aFileList[$i],3)
                                $aNewList[$i] = FileReadLine($aFileList[$i],4)



                Next

        ;       Local $aItems
    ;For $iI = 0 To UBound($aItems) - 1
    ;    $aItems[$iI] = "Item " & $iI
    ;Next
    ;$iTimer = TimerInit()

    _GUICtrlListView_AddArray($idListview, $aNewList)


        ;$idListview=_ArrayDisplay($aNewList, "Test Management v1.0", Default, 32 + 64, Default, "Tester|Test Item|BMC|Count|Last Record Time|...|...|...|...", Default, 0xDDFFDD)

Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()

EndIf


131738 发表于 2016-5-13 16:52:17

看看 GUICtrlCreateList 函数示例脚本, 能力有限,我最怕写代码了............

Alam 发表于 2016-5-13 18:10:02

回复 5# ipmitool
    #include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
;#include <MsgBoxConstants.au3>

GUICreate("ListView Add Array", 800, 300)
$idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
GUISetState(@SW_SHOW)
_GUICtrlListView_AddColumn($idListview, "Tester", 100)
_GUICtrlListView_AddColumn($idListview, "Test Item", 100)
_GUICtrlListView_AddColumn($idListview, "BMC IP", 100)
_GUICtrlListView_AddColumn($idListview, "Count", 100)
_GUICtrlListView_AddColumn($idListview, "Last Record Time", 100)
_GUICtrlListView_SetItemCount($idListview, 5000)
_add_lv_items()
AdlibRegister('_add_lv_items', 5000); 5秒刷新数据
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()


Func _add_lv_items()
        Local $path, $aFileList, $aNewList
        $path = @ScriptDir
        $aFileList = _FileListToArray($path, "*.txt")
        If IsArray($aFileList) Then

                ReDim $aNewList ;;;
                For $i = 0 To UBound($aFileList) - 1 Step 1
                        $aNewList[$i] = $aFileList[$i]
                        $aNewList[$i] = FileReadLine($aFileList[$i], 1)
                        $aNewList[$i] = FileReadLine($aFileList[$i], 2)
                        $aNewList[$i] = FileReadLine($aFileList[$i], 3)
                        $aNewList[$i] = FileReadLine($aFileList[$i], 4)

                Next
                _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($idListview))
                _GUICtrlListView_AddArray($idListview, $aNewList)
        EndIf
EndFunc

ipmitool 发表于 2016-5-13 18:57:23

回复 7# Alam


    挖賽, 解決了!!!好厲害, 這裡的人都好強~~~謝謝妳喔!!!

ipmitool 发表于 2016-6-2 08:35:25

回复ipmitool
Alam 发表于 2016-5-13 18:10 http://www.autoitx.com/images/common/back.gif


    請問大大, 要如何讓滑鼠點擊某一行˙兩下之後, 讀出點到的值, 然後帶到msgbox呢? Thanks

Alam 发表于 2016-6-2 18:18:08

回复 9# ipmitool #include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

GUICreate("ListView Add Array", 800, 300)
$idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
GUISetState(@SW_SHOW)
_GUICtrlListView_AddColumn($idListview, "Tester", 100)
_GUICtrlListView_AddColumn($idListview, "Test Item", 100)
_GUICtrlListView_AddColumn($idListview, "BMC IP", 100)
_GUICtrlListView_AddColumn($idListview, "Count", 100)
_GUICtrlListView_AddColumn($idListview, "Last Record Time", 100)
_GUICtrlListView_SetItemCount($idListview, 5000)
_add_lv_items()
AdlibRegister('_add_lv_items', 5000); 5秒刷新数据
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")   
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()

Func _add_lv_items()
      Local $path, $aFileList, $aNewList
      $path = @ScriptDir
      $aFileList = _FileListToArray($path, "*.txt")
      If IsArray($aFileList) Then
                ReDim $aNewList ;;;
                For $i = 0 To UBound($aFileList) - 1 Step 1
                        $aNewList[$i] = $aFileList[$i]
                        $aNewList[$i] = FileReadLine($aFileList[$i], 1)
                        $aNewList[$i] = FileReadLine($aFileList[$i], 2)
                        $aNewList[$i] = FileReadLine($aFileList[$i], 3)
                        $aNewList[$i] = FileReadLine($aFileList[$i], 4)
                Next
                _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($idListview))
                _GUICtrlListView_AddArray($idListview, $aNewList)
      EndIf
EndFunc
       
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = GUICtrlGetHandle($idListview)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
      Case $hWndListView
            Switch $iCode
                                Case $NM_DBLCLK ;鼠标双击
                  $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                  $Index= DllStructGetData($tInfo, "Index")
                                        MsgBox(0, '', _GUICtrlListView_GetItemTextString($hWndListView, $Index))
                        EndSwitch
        EndSwitch
EndFunc       
                       

ipmitool 发表于 2016-6-2 18:44:07

Wow, 感謝你, 如果只要抓取點選到的那一個值呢? 謝謝你

ipmitool 发表于 2016-6-7 10:06:23

請問如何偵測每行資料, 10分鐘沒更新狀態, 就回報msg error呢? 謝謝各位大大
页: [1]
查看完整版本: [已解決]請問如何讓 array 顯示在GUI裡面? 然後每秒更新一次array