Pera Posted January 10, 2007 Posted January 10, 2007 Hi there, I am trying to get the text within a .log file that is being updated by the game as events progress. I used WinGetText; [/autoit] $TexttobeRead = WinGetText("Chat.log -", "") [autoit] However, as the chat.log updates it doesn't actually update in the open document. Is there a way to capture the text within chat.log in real time? I than would like to use StringInStr to compare the text with a substring. Thanks in advance
BALA Posted January 10, 2007 Posted January 10, 2007 You could create a loop that would continuously check [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Pera Posted January 10, 2007 Author Posted January 10, 2007 You could create a loop that would continuously checkI did the loop with WinGetText, however when I have the "chat.log" open, whatever is in the open file is actually being captured by WinGetText. In the meantime the game is still updating chat.log on the background but the updates doesn't display in the open file. I hope it makes sense...
BALA Posted January 10, 2007 Posted January 10, 2007 (edited) Oh, I see. Have you tried using a "read string"-type command? EDIT: I don't know if I'm giving the correct term... Edited January 10, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Pera Posted January 10, 2007 Author Posted January 10, 2007 Oh, I see. Have you tried using a "read string"-type command?EDIT: I don't know if I'm giving the correct term...I am not sure if I know any string commands that will get the text within a file?
Pera Posted January 10, 2007 Author Posted January 10, 2007 I am not sure if I know any string commands that will get the text within a file?I really appreciate for even the smallest tip on this... I have been working on it forever heh...
Moderators SmOke_N Posted January 10, 2007 Moderators Posted January 10, 2007 I really appreciate for even the smallest tip on this... I have been working on it forever heh...FileRead()? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Pera Posted January 10, 2007 Author Posted January 10, 2007 FileRead()? Well I tried this real fast to test it and it doesn't open "chat.log", actually when I run the script, nothing happens... [/autoit] $file = FileOpen("chat.log", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf While 1 $chars = FileRead($file, 1) If @error = -1 Then ExitLoop MsgBox(0, "Char read:", $chars) Wend FileClose($file) [autoit]
Joon Posted January 10, 2007 Posted January 10, 2007 I'm not sure whether you want to read Window Text or text file... Try this it should be fine if it's log and appending to the end... #include <File.au3> Dim $aChatlog, $TotalLine $chatlog = @ScriptDir & "\chat.log" $TimeStamp = FileGetTime($chatlog, 0, 1) _FileReadToArray($chatlog, $aChatlog) $TotalLine = $aChatlog[0] While 1 If FileGetTime($chatlog, 0, 1) <> $TimeStamp Then $TimeStamp = FileGetTime($chatlog, 0, 1) _FileReadToArray($chatlog, $aChatlog) If IsArray($aChatlog) Then $newLines = "" For $i = $TotalLine To $aChatlog[0] $newLines &= $aChatlog[$i] & @CRLF Next EndIf MsgBox (0,"Changed","New line(s) : " & @CRLF & $newLines) EndIf Sleep(1000) WEnd
Pera Posted January 10, 2007 Author Posted January 10, 2007 (edited) Hey thanks fo rthe script. I tried it and it gives an error in line 7... Edited January 10, 2007 by Pera
Joon Posted January 10, 2007 Posted January 10, 2007 Hey thanks fo rthe script. I tried it and it gives an error in line 7... I think you are having a problem reading a file. change this section and try. #include <File.au3> Dim $aChatlog, $TotalLine $chatlog = @ScriptDir & "\chat.log" $TimeStamp = FileGetTime($chatlog, 0, 1) If Not _FileReadToArray($chatlog, $aChatlog) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf $TotalLine = $aChatlog[0]
Pera Posted January 11, 2007 Author Posted January 11, 2007 I think you are having a problem reading a file. change this section and try. #include <File.au3> Dim $aChatlog, $TotalLine $chatlog = @ScriptDir & "\chat.log" $TimeStamp = FileGetTime($chatlog, 0, 1) If Not _FileReadToArray($chatlog, $aChatlog) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf $TotalLine = $aChatlog[0] I am getting message "error reading log to array: 1". Sorry I am causing a lotof trouble...
Moderators SmOke_N Posted January 11, 2007 Moderators Posted January 11, 2007 (edited) You don't have the right file location more than likely. All of the options provided will work, but you have to replace: $chatlog = "Change This to the actual location, not just "chat.log""oÝ÷ ØGbµ§¶¬jëh×6Global $hChatLog = 'chat.log', $sString = '' If Not FileExists($hChatLog) Then MsgBox(16, 'Error', 'File Does not exist here') Exit -1 EndIf $sString = FileRead($hChatLog) MsgBox(64, 'Info', 'File Contains: ' & @CR & @CR & $sString) Edited January 11, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Pera Posted January 11, 2007 Author Posted January 11, 2007 You don't have the right file location more than likely. All of the options provided will work, but you have to replace: $chatlog = "Change This to the actual location, not just "chat.log""oÝ÷ ØGbµ§¶¬jëh×6Global $hChatLog = 'chat.log', $sString = '' If Not FileExists($hChatLog) Then MsgBox(16, 'Error', 'File Does not exist here') Exit -1 EndIf $sString = FileRead($hChatLog) MsgBox(64, 'Info', 'File Contains: ' & @CR & @CR & $sString) Guys I really appreciate all of your help. I finally figured this out. My file location was incorrect. Well it was correct but it was under a different user account than what I used Thanks a lot once again!
ihudson Posted February 1, 2007 Posted February 1, 2007 Check out ABLogFile at www.amleth.com free realtime log file reader with nice options. Hope this helps, at least to see it in action.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now