16 posts in this topic
Parse time from each line of log (text file)
I have another AutoIT script making a Log file
Sample of Log file:
2016/08/22 12:44:18 > Process: [RUNNING] [ACTIVE] 2016/08/22 12:48:35 > Process: [WAS NOT RUNNING] 2016/08/22 13:40:00 > Process: [FAILED] 2016/08/22 14:01:10 > Process: [WAS NOT RUNNING] I am looping through the Log file for the word "FAILED"
I then want to get all lines that have "FAILED" and get their TIME
My Current code to get this far:
If FileExists($fileLog) Then $contents = FileRead($fileLog) If @error Then MsgBox(0, 'File Error', $fileLog & ' could not be read.') Else For $i = 1 To _FileCountLines($fileLog) $result = StringInStr($contents,$search) If $result >= 1 Then $filteredLine = FileReadLine($fileLog,$i) If StringInStr($filteredLine,$search) Then ConsoleWrite($filteredLine & @CRLF) ; this gets me the results I want sans the time parse EndIf Else ConsoleWrite( $search & " not found!" & @CRLF) EndIf Next EndIf EndIf For this part:
If StringInStr($filteredLine,$search) Then ConsoleWrite($filteredLine & @CRLF) ; this gets me the results I want sans the time parse EndIf OUTPUT: 2016/08/22 13:40:00 > Process: [FAILED] I dont understand how I read the time in that output?
I have tried _DateTimeFormat - Dont think this applies
Tried _DateDiff - I dont have a the date yet so this doesnt work
Would love if someone could tell me if I am thinking is the wrong direction and possibly lead me down the correct path to light side of the force
Capture Screenshot using snipping tool
I've created a simple script that opens the Snipping Tool; Selects the "Full Screen Snip" option; then closes the program, prompting a save. What I can't figure is how to name the file using the system date and time.
Can anyone help?
Run(@WindowsDir & '\system32\SnippingTool.exe') AutoItSetOption('MouseCoordMode', 0) Sleep(1) $hWnd= WinWait("Snipping Tool", "ToolBarWindow32", 1) WinActive($hWnd) MouseClick('primary', 84, 48, 1, 0) MouseClick('primary', 84, 140, 1, 0) WinClose("[Class:Microsoft-Windows-Tablet-SnipperEditor]") ControlClick("Snipping Tool", "", "Button1")
How i can compare two dates?
Hi to all
My problem is how can I compare two dates
if I have the following code:
$date = _NowDate() $dateend = "10/12/2016" if $date > $dateend Then Exit EndIf It does not work well
I guess it's because I'm comparing two strings not realy two dates.
My idea would break the date into three numbers year, month and day and go comparing data as numbers.
is this correct...?
Thank's to all
Date difference is not working
I am assigning the current time stamp to a variable $strtTime and holding the execution for 5 seconds with Sleep and calculating the current time stamp.
Ideally, the _DateDiff should give 5 seconds as output as i gave the parameter as s.But it is giving zero 0.
Global $startTime = _Date_Time_GetLocalTime() $startTime = _Date_Time_SystemTimeToDateTimeStr($startTime) Sleep(5000) $tCur = _Date_Time_GetLocalTime() $tCur = _Date_Time_SystemTimeToDateTimeStr($tCur) $iDateCalc = _DateDiff('s', $startTime, $tCur) MsgBox(0,"$iDateCalc",$iDateCalc) FileWrite ($QTPfile,CHr(34) & $tCur & CHr(34) & Chr(44) & """" & $iDateCalc & """,")
comparing dates in autoit
I'm trying to make a script that runs different functions depending on the local time of the computer
I tried to do
if _NowCalcDate < 2016/04/12 Then
and that doesn't seem to work.
I am assuming that value returned from _NowCalcDate doesn't match with the date type I wrote
What should I do? I'd appreciate for any help that's given.