SpookMeister Posted July 20, 2009 Share Posted July 20, 2009 I currently have a script that is working fairly well, lets say that it is accurate 90% of the time, at detecting when a desired event is happening by reading visual clues from another program's display. However, I have recently learned that the program being monitored also has a logging option I can enable that would include (among many other things) the triggering of the event I want to catch. I would like to use this feature to improve my script's accuracy if I can, but I'm not sure how to proceed. Does anyone have some advice/pointers on how I go about monitoring new data as it is added to this log file for the event I am looking for? I'm thinking that constantly re-reading the entire data file trying to get the new data will be far more CPU/HDD intensive than I can afford. [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
evilertoaster Posted July 20, 2009 Share Posted July 20, 2009 If the other program only outputs to a text file your real time logging options are limited. Depending on how the log file is updated it might not even be an option. Does the log file get written to in real time? Or does it write it all-at-once when the program wants to... If it does write it real time it technically has to open and close the handle too. Likewise, you'd have to reopen the handle (re-read the file) to get any new information. It would be nice if the logging was piped to the output stream or something, but with a text file I don't know... Link to comment Share on other sites More sharing options...
KaFu Posted July 21, 2009 Share Posted July 21, 2009 Constantly check the log-file filetime (modified), if it has changed read the last (assumed new data is appended) some thousand byte with _WinAPI_CreateFile()+_WinAPI_SetFilePointer() and parse new results. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
SpookMeister Posted July 21, 2009 Author Share Posted July 21, 2009 (edited) Constantly check the log-file filetime (modified), if it has changed read the last (assumed new data is appended) some thousand byte with _WinAPI_CreateFile()+_WinAPI_SetFilePointer() and parse new results.Thanks KaFu,This sounds like what I'm looking for. I'm looking at the help file now and will play with it, but at first glance implementation is not obvious to me (of the WinAPI parts). If you feel up to it, could you see your way to give a little example, even pseudo-code would be of great help.Thanks again,-Spook Edited July 21, 2009 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
SpookMeister Posted July 21, 2009 Author Share Posted July 21, 2009 Nevermind KaFu, Figured it out... was just scared I guess [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
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