本帖最后由 yangyangban 于 2016-12-25 23:13 编辑
回复 4# Alam
大神,我现在改了程序,怎么运行到最后总是出现这个问题呢?不管是否打开结果文件,还是不打开,都会报错,帮帮看一下
[img][/img]#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Date.au3>
#include<string.au3>
#include <EditConstants.au3>
#include<array.au3>
#Region ### START Koda GUI section ### Form=
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=ico.ico
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
Global $RM
Global $NAME
Global $label2
Global $Filename1=1
$Form1 = GUICreate("welcome", 482, 285, 650, 250)
$Pic1 = GUICtrlCreatePic("", 25, 35, 180, 200)
GUICtrlSetImage($Pic1, @WorkingDir&"\13.jpg")
$Button1 = GUICtrlCreateButton("About",420, 6, 50, 23)
$Button2 = GUICtrlCreateButton("OPEN R7590", 250,45, 75, 33)
$label3 = GUICtrlCreateLabel("RM2-8086_8191",350,55, 95, 33)
GUICtrlSetFont(1, 10, 800, 0, "")
$Button3 = GUICtrlCreateButton("OPEN R7553", 250, 105, 75, 43)
$label4 = GUICtrlCreateLabel("RM2-8086_8085",350,115, 95, 43)
GUICtrlSetFont(1, 10, 800, 0, "")
$Button4 = GUICtrlCreateButton("OPEN R7707", 250, 180, 75, 33)
$label5 = GUICtrlCreateLabel("RM2-8525_8524",350,190, 95, 43)
GUICtrlSetFont(1, 10, 800, 0, "")
Sleep(50)
$Label5 = GUICtrlCreateLabel("Time:"&_Now(), 280, 260, 200, 16)
GUICtrlSetFont(-1, 10, 800, 0, "")
GUICtrlSetColor(-1, 0x0000ff)
Global $t2, $t3 = 1
$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 1000, "ptr", DllCallbackGetPtr($Timer))
$Timer2 = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$Timer2DLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 200, "ptr", DllCallbackGetPtr($Timer2))
$Timer3 = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$Timer3DLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 500, "ptr", DllCallbackGetPtr($Timer3))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;Local $TIMEIN =InputBox("Time Input"," 请输入需要查询的日期:"& @CRLF& "(不输入则默认当前时间)" & @CRLF& " 格式:20160102","","",200,160,100,100)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Case $Button2
ShellExecute( MODEL(7590, 8191), "", "", "open")
Case $Button3
ShellExecute( MODEL(7553, 8085), "", "", "open")
Case $Button4
ShellExecute( MODEL(7707,8524), "", "", "open")
EndSwitch
WEnd
Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)
If $idEvent = $TimerDLL[0] Then
GUICtrlSetData($Label5, "Time:"&@YEAR &"-"&@MON&"-"&@MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC )
EndIf
EndFunc
Func MODEL($NAME, $RM)
Local $TIMEIN
Local $MNAME = "R" &$NAME
If $RM=8191 Then $RM="RM2-8086_8191"
IF $RM=8085 Then $RM="RM2-8086_8085"
IF $RM=8524 Then $RM="RM2-8525_8524"
Local $readResult=@WorkingDir & "\" & $MNAME &"result.Log";read result add 结果文档输出路径
if FileExists($readResult) then FileDelete($readResult)
Dim $space
local $failtotal=0;all fail total
if FileExists($readResult) then FileDelete($readResult)
;文件名处理
Local $sFile = @YEAR & @MON & @MDAY ; get log file name 获取文件名Local
Local $YEAR = StringTrimRight($sFILE,4)
Local $MON = StringMid($sFILE,5,2)
Local $DAY = StringRight($sFILE,2)
Local $shijian=MsgBox(4, 'time', " You will chck time is : " & @CRLF & @CRLF &@YEAR &"-"&@MON&"-"&@MDAY & @CRLF & @CRLF &" Yes or not? if not pls input the time ");
if $shijian=6 then
$sFile= StringRight($sFile,6) & 'e'
EndIf
If $shijian=7 then
$TIMEIN =InputBox("Time Input"," 请输入需要查询的日期:"& @CRLF& @CRLF& @CRLF& " 格式:20160102","","",200,200,710,350);长,宽,右,左,
;判断输入日期是否正确
Local $MON1 = StringMid($TIMEIN,5,2)
Local $DAY2 = StringRight($TIMEIN,2)
While StringLen($TIMEIN)<>8 Or $MON1 <=0 Or $MON1 >12 Or $DAY2 <=0 Or $DAY2 >31
If $TIMEIN="exit" then exit
$TIMEIN=InputBox("Time Input"," 日期不正确,请重新输入" & @CRLF& @CRLF& @CRLF& " 格式:20160102","","",200,200,710,350)
$MON1 = StringMid($TIMEIN,5,2)
$DAY2 = StringRight($TIMEIN,2)
WEnd
$sFile=StringTrimLeft($TIMEIN,2) & 'e'
EndIf
Dim $filenam= ""&$sFile&".log"
MsgBox(32, 'Log file name', $filenam);Display name 显示文件名
Local $filename=@WorkingDir&"\"& $RM&"\ErrorLog\"&$sFile&".log" ;add+file name 路径结合文件名
$filename= $filename
Local $Read_file=FileRead ($filename)
ClipPut($Read_file)
Local $sTxt = ClipGet() ; fileread($sFile) ;fileread读取文件内容,需注意路径
Local $aRe = StringRegExp($sTxt, 'Step[^:]+', 3) ;get all the test fail step正则提取所有的 stepX
If @error Then Exit MsgBox(16, 'ERROR', 'No step found')
$aRe = _ArrayUnique($aRe) ; 去除重复的 stepX
If @error <> 0 Then Exit MsgBox(16, 'ERROR', 'ERROR in aRe')
For $i = 1 To $aRe[0]
StringReplace($sTxt, $aRe[$i], '')
Local $iN = @extended ;用替换法,快速获取每一个 stepX 在文件中的数量
$failtotal=$failtotal+$iN;all step fail total
FileWrite($readResult,"Step Name:"& $aRe[$i]&@CRLF);weite STEP name
FileWrite($readResult,"Fail Total:" & $iN&@CRLF) ;fail total总数量
FileWrite($readResult,""& $space&@CRLF)
Next
FileWrite($readResult,"All Step Fail Total:" & $failtotal&@CRLF) ;fail total总数量;display all fail total
Local $fanhui=MsgBox(4, 'Result', " Congratulations ,Finish!!!" & @CRLF& "" & @CRLF& " Open the file or not?");
if $fanhui=6 then ShellExecute($readResult, "", "", "open")
If $fanhui=7 then FileClose($readResult)
EndFunc
|