Jump to content

Recommended Posts

Posted

There is a certain program that is always writing to a log file that is in text format. How can AutoIt be used to constantly monitor what is being written to this text file and take certain actions depending on what new output it sees?

Posted (edited)

i coded this filewatcher ~~ one week ago

; File watcher

$INI = @ScriptDir & "\Settings.ini"
$filename = IniRead($INI, "watching", "filename", ""); Filename
$string = IniRead($INI, "watching", "stringtosearch", ""); String writed to file by bot
$do = IniRead($INI, "watching", "filerun", ""); Run a file after text in file
$exit = IniRead($INI, "watching", "exitiffound", ""); Exit if string was found?

$delay = IniRead($INI, "delays", "searchdelay", ""); Time between loop wil check file again

$File = FileOpen($filename, 0) ; 0 - Read Mode

While 1
If FileReadLine($filename, 1) = $string Then ; If first line of file is our string then...
    ShellExecute($do); Run a file
        If $exit = "true" Then
            Exit
        Else
            ContinueLoop
        EndIf
EndIf
sleep($delay * 1000)
WEnd

FileClose($File)

This should be useful for u

Edited by Sobiech

This world is crazy

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...