找回密码
 加入
搜索
查看: 1719|回复: 5

[AU3基础] 如何抓取 txt 的 Memory 字元的前面三個 0x 裡面的英數字 並且output

[复制链接]
发表于 2016-8-3 11:33:03 | 显示全部楼层 |阅读模式
本帖最后由 ipmitool 于 2016-8-3 11:45 编辑

請問如何抓取 txt 檔案裡面的 Memory 字元的前面三個 0x 裡面的英數字, 然後個別 output 到GUICtrlCreateInput 裡面?

ipmitool -H bncip -U Admin -P Admin -I lanplus sel save xx.txt
0x04 0x10 0x02 0x6f 0x02 0xff 0xff # Event Logging Disabled #0x02 Log area reset/cleared
0x04 0x0c 0xd2 0x6f 0xa0 0x00 0x00 # Memory #0xd2 Correctable ECC
0x04 0x0c 0xd2 0x6f 0xa0 0x00 0x51 # Memory #0xd2 Correctable ECC
0x04 0x0c 0xd2 0x6f 0xa0 0x00 0x01 # Memory #0xd2 Correctable ECC
0x04 0x0c 0xd2 0x6f 0xa0 0x00 0x18 # Memory #0xd2 Correctable ECC
#include <Array.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiComboBoxEx.au3>


#include<array.au3>
#include <Excel.au3>

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>



$Form1 = GUICreate("Collect FIO Log Tool", 520, 540, -1, -1)

$Radio1        = GUICtrlCreateRadio("Collect1", 400, 50, 97, 25)
$Radio2        = GUICtrlCreateRadio("Collect2", 400, 80, 97, 25)
$Radio3        = GUICtrlCreateRadio("Collect3", 400, 110, 97, 25)

;$Button0 = GUICtrlCreateButton("Get BW/IOPS/CPU%", 5, 5, 140, 25, 0)
$Button1 = GUICtrlCreateButton("Analyze", 400, 150, 97, 50, 0)


$hLabel1 = GUICtrlCreateLabel("EventData", 30, 14, 97, 25, 0)
$hLabel2 = GUICtrlCreateLabel("EventData", 150, 14, 97, 25, 0)
$hLabel3 = GUICtrlCreateLabel("EventData", 270, 14, 97, 25, 0)

    GUISetState(@SW_SHOW)



;######################################################################
        Local $open, $exititem, $helpmenu, $aboutitem, $aboutitemRaw, $aboutitemFile;, $okbutton, $cancelbutton
        Local $msg;, $file
        $filemenu = GUICtrlCreateMenu("File")
        $open = GUICtrlCreateMenuItem("Open", $filemenu)
        $exititem = GUICtrlCreateMenuItem("Exit", $filemenu)

;######################################################################


   ; HotKeySet("^c", "MyExit");設定中斷熱鍵

    Local $var = FileOpenDialog("Please select which Log you want to sorting...", @ScriptDir, " Please Select File (*.txt)")
    Local $file = FileOpen($var)

   $Input1 = GUICtrlCreateEdit("", 30, 30, 100, 175)
   $Input2 = GUICtrlCreateEdit("", 150, 30, 100, 175)
   $Input3 = GUICtrlCreateEdit("", 270, 30, 100, 175)

        ;HotKeySet("{enter}","_F1")
        GUICtrlCreateLabel("Data1", 35, 215, 50, 23)
        GUICtrlCreateLabel("Data2", 105, 215, 50, 23)
        GUICtrlCreateLabel("Data3", 180, 215, 50, 23)

        $out_collect1 = GUICtrlCreateInput("", 30, 230, 50, 23)
        $out_collect2 = GUICtrlCreateInput("", 100, 230, 50, 23)
        $out_collect3 = GUICtrlCreateInput("", 175, 230, 50, 23)

        $out_collect4 = GUICtrlCreateInput("", 30, 280, 50, 23)
        $out_collect5 = GUICtrlCreateInput("", 100, 280, 50, 23)
        $out_collect6 = GUICtrlCreateInput("", 175, 280, 50, 23)

        $out_collect7 = GUICtrlCreateInput("", 30, 330, 50, 23)
        $out_collect8 = GUICtrlCreateInput("", 100, 330, 50, 23)
        $out_collect9 = GUICtrlCreateInput("", 175, 330, 50, 23)

Func _F1()
                send("{Tab}")
EndFunc

;send("^z")



While 1
    ;read printer information
    $line = FileRead($file)
    $prn000 = StringRegExp($line, "0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) # Memory", 3)
        $prn001 = StringRegExp($line, "0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) # Memory", 3)
        $prn002 = StringRegExp($line, "0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) # Memory", 3)


for $i = 0 to UBound($prn000) - 1
$CollectHDD1 = GUICtrlSetData ($Input1, $prn000[$i] &@CRLF,1)
$CollectHDD11 = ControlGetText("Collect1","",10)
  Next

for $j = 0 to UBound($prn001) - 1
$CollectHDD2 = GUICtrlSetData ($Input2, $prn001[$j] &@CRLF,1)
$CollectHDD22 = ControlGetText("Collect2","",11)
  Next

for $k = 0 to UBound($prn002) - 1
$CollectHDD3 = GUICtrlSetData ($Input3, $prn002[$k] &@CRLF,1)
$CollectHDD33 = ControlGetText("Collect3","",12)
  Next



        $Msg = GUIGetMsg()
        Switch $Msg
                Case $GUI_EVENT_CLOSE
                        Exit

                Case $Button1

        if BitAnd(GUICtrlRead($Radio1),$GUI_CHECKED)=1 Then
                        MsgBox(0,"123","123",1)
        EndIf



        if BitAnd(GUICtrlRead($Radio2),$GUI_CHECKED)=1 Then
                        MsgBox(0,"123","123",1)
        EndIf



        if BitAnd(GUICtrlRead($Radio3),$GUI_CHECKED)=1 Then
                        MsgBox(0,"123","123",1)
        EndIf


EndSwitch

;######################################################################

                Select
                        Case $msg = $exititem
                                ExitLoop

                        Case $msg = $open
                                Local $var = FileOpenDialog("Please select which Log you want to sorting...", "c:", " Please Select File (*.txt)")
                                Local $file = FileOpen($var)

                                        ;Case $msg = $okbutton
                                        ;        MsgBox(0, "Click", "You clicked OK!")


                EndSelect


;######################################################################



WEnd
 楼主| 发表于 2016-8-4 08:11:09 | 显示全部楼层
請問有大師有辦法處理這一條難解的問題嗎? 拜託了~
发表于 2016-8-4 11:34:14 | 显示全部楼层
http://www.autoitx.com/thread-38736-1-1.html 如果你的字符内容是固定的 那么难度不高  如果只是大致格式固定 那么你还得等后来者帮忙。
 楼主| 发表于 2016-8-4 13:35:57 | 显示全部楼层
內容不是固定的...會變, 只是格式是一樣的. 只要取最後三個 0x 裡面的英數字元
发表于 2016-8-4 14:12:48 | 显示全部楼层
(?mi)0x(\S+)\h+0x(\S+)\h+0x(\S+)\h+#\h+Memory\h+
发表于 2016-8-6 15:38:58 | 显示全部楼层
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-20 17:44 , Processed in 0.082390 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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