找回密码
 加入
搜索
查看: 2854|回复: 11

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

  [复制链接]
发表于 2016-5-13 08:03:28 | 显示全部楼层 |阅读模式
本帖最后由 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[1][2]
$path = @ScriptDir
$aFileList = _FileListToArray($path, "*.txt")
If IsArray($aFileList) Then
        ReDim $aNewList[UBound($aFileList)][2]
        For $i = 0 To UBound($aFileList) - 1 Step 1
                $aNewList[$i][0] = $aFileList[$i]
                $aNewList[$i][1] = FileRead($aFileList[$i])
        Next
        _ArrayDisplay($aNewList, "$aFileList")
EndIf
 楼主| 发表于 2016-5-13 15:01:10 | 显示全部楼层
大大們有沒有招啊...拜託幫幫忙~
发表于 2016-5-13 15:43:30 | 显示全部楼层
循环写数组值到列表视图不行吗?........
 楼主| 发表于 2016-5-13 15:51:56 | 显示全部楼层
功力不夠...麻煩大大幫忙了...
 楼主| 发表于 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[1][2]
$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[UBound($aFileList)][5]   ;;;[Col count]
        For $i = 0 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)



                Next

        ;         Local $aItems[1000][1]
    ;For $iI = 0 To UBound($aItems) - 1
    ;    $aItems[$iI][0] = "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
发表于 2016-5-13 16:52:17 | 显示全部楼层
看看 GUICtrlCreateList 函数示例脚本, 能力有限,我最怕写代码了............
发表于 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[1][2]
        $path = @ScriptDir
        $aFileList = _FileListToArray($path, "*.txt")
        If IsArray($aFileList) Then

                ReDim $aNewList[UBound($aFileList)][5] ;;;[Col count]
                For $i = 0 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)

                Next
                _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($idListview))
                _GUICtrlListView_AddArray($idListview, $aNewList)
        EndIf
EndFunc 
 楼主| 发表于 2016-5-13 18:57:23 | 显示全部楼层
回复 7# Alam


    挖賽, 解決了!!!好厲害, 這裡的人都好強~~~謝謝妳喔!!!
 楼主| 发表于 2016-6-2 08:35:25 | 显示全部楼层
回复  ipmitool
Alam 发表于 2016-5-13 18:10



    請問大大, 要如何讓滑鼠點擊某一行˙兩下之後, 讀出點到的值, 然後帶到msgbox呢? Thanks
发表于 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[1][2]
        $path = @ScriptDir
        $aFileList = _FileListToArray($path, "*.txt")
        If IsArray($aFileList) Then
                ReDim $aNewList[UBound($aFileList)][5] ;;;[Col count]
                For $i = 0 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)
                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        
                        
 楼主| 发表于 2016-6-2 18:44:07 | 显示全部楼层
Wow, 感謝你, 如果只要抓取點選到的那一個值呢? 謝謝你
 楼主| 发表于 2016-6-7 10:06:23 | 显示全部楼层
請問如何偵測每行資料, 10分鐘沒更新狀態, 就回報msg error呢? 謝謝各位大大
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-22 00:31 , Processed in 0.083884 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表