The script runs without any syntax errors but I have 3 issues
1. I suspect the syntax of the InStr might be off but not sure.
2. The regex command is slightly off - in it's current form it returns the keyword+white space+full number, not just the "00" I'm looking for. I can't seem to quite get it so it only matches on "00"
3. The MsgBox does not pop up
The script is as follows. The test file is also attached. Any help in fixing so it works as required is appreciated !
Code: Select all
FilePath := A_ScriptDir "\TestLogFile2.txt" ; relative path to file
File := FileOpen(FilePath, "r")
OldLogFileSize := 0
File.Seek(0, 2) ; move the file pointer to the end of the file to start reading newly added lines
Loop
{
LogFileSize := File.Length
if (LogFileSize > OldLogFileSize)
{
Loop
{
if File.AtEOF
Break
TextLine := File.Readline()
If InStr(TextLine, seed) ;searching for keyword
{
RegExMatch(TextLine, "\bseed\s+\d*00$", RFNum) ;find keyword then match 00 at the end of the number after keyword
MsgBox, % "The ID is " RFNum ; Display number. Change this to action once working
}
}
OldLogFileSize := LogFileSize
}
Sleep, 1000 ; wait one second before checking again (change to whatever)
}
return
Esc::
File.Close()
ExitApp
return