20 posts in this topic
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
Multi-monitor aware window centring function. Can handle various work area setups as outlined below:
Those are the variants I've tested.
#include <Math.au3> #include <WinAPI.au3> #include <WinAPIConstants.au3> #include <WinAPIGdi.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> Func activeWindowCenter() Const $window = WinGetHandle('[ACTIVE]') Const $monitorInfo = _WinAPI_GetMonitorInfo(_WinAPI_MonitorFromWindow($window)) Const $area = [DllStructGetData($monitorInfo, 1), DllStructGetData($monitorInfo, 3), DllStructGetData($monitorInfo, 2), DllStructGetData($monitorInfo, 4)] Const $size = WinGetPos($window) If @error Then Return EndIf If BitAND(_WinAPI_GetWindowLong($window, $GWL_STYLE), $WS_MAXIMIZE) Then Return EndIf Const $areaWidth = _Max($area, $area) - _Min($area, $area) Const $windowOffsetX = ($areaWidth - $size) / 2 Const $x = _Min($area, $area) + $windowOffsetX Const $areaHeight = _Max($area, $area) - _Min($area, $area) Const $windowOffsetY = ($areaHeight - $size) / 2 Const $y = _Min($area, $area) + $windowOffsetY WinMove($window, '', $x, $y, $size, $size, 2) EndFunc Here's simple usage:
; include the definition HotKeySet('#o', 'activeWindowCenter') While 1 Sleep(1000) WEnd
I was searching for a while now and didn't find anything regarding this:
Is there a function that returns the "number" of the monitor where the mouse is currently on screen? The same number that appears when you open windows-resolution and click on "identify" (or something). I want to trigger an event when the number changes. I wrote something that recognizes leaving the main monitor. But I couldn't get any further than that (maybe with _WinAPI_EnumDisplayMonitors/Devices/Settings ?) and I wouldn't catch an event, if someone has 3 monitors (aligned 1--2--3 with 1 being main monitor) and changes from 2 to 3.
Here is my code:
The GUI was just for testing. Maybe you can give me some hints :)?
Hello, first time poster here
I am working on a project that has to parse a log file in real time. The thing is I know it's hard for Autoit to attach itself to log files when they're already in use by other programs, at least in my experience.
I was taking a look at this thread because the log file is quite large and I think Autoit might be a little slow on it's own.
The thing is I don't know how to use this properly to extract all data out of a log file or is there a native way to do this using Autoit.
Basically , I just need a log parser that is able to read from a log that is 'already opened' and 'being written to'
I have been a member for a while but relatively new to posting to the message boards. I am also still relatively new to using AutoIt. I am working on a script that will help keep a program running on one of my file servers.
Here is what I have accomplished so far looking at different threads on the site already.
1. A check performed every 60 seconds to see if the application is running. (ultimately to be changed to something like once an hour)
2. Write a log file that shows either the check was performed with no issue or the application had to be restarted.
Both of those are working fine and I have to say that ever since I started using this script the program has not crashed!
My next phase is to figure out how to make the script check and trim the log file. I am obviously not trying to make a log file that becomes bloated and chews up a large amount of hard drive space. The main purpose of the log file is so that I know if the application has been restarted. I am thinking have the script trim the file every 30 day maybe. Another words delete everything in the log file 30 days prior to the current day. So if someone can help me out here as I am not a scripting genius. Unfortunately I only know enough to be dangerous if you will.
I also have another part of this script I want to write but first I want to get the log file working just the way I want. I am attaching a sample of what I have working so far.
Thank you for any and all help folks.
#include <File.au3> While 1 ;Start Loop If ProcessExists("atcsmon.exe") Then ;~ Open the logfile in write mode. Local $hFile = FileOpen(@ScriptDir & "\ATCS_AutoIt.log", 1) _FileWriteLog($hFile, "ATCS check was completed and found running by the AutoIt3 Script") ; Write to the logfile passing the filehandle returned by FileOpen. FileClose($hFile) ; Close the filehandle to release the file. Else ;If Process does not exist Run("C:\atcs_monitor\atcsmon.exe", "", @SW_SHOWMINIMIZED) ;~ Open the logfile in write mode. Local $hFile = FileOpen(@ScriptDir & "\ATCS_AutoIt.log", 1) _FileWriteLog($hFile, "*ALERT* *ALERT* *ALERT* ATCS was restarted by the AutoIt3 Script") ; Write to the logfile passing the filehandle returned by FileOpen. FileClose($hFile) ; Close the filehandle to release the file. EndIf Sleep(60000) ;sleep 60 seconds WEnd ;Close Loop