AcidicChip Posted September 2, 2006 Share Posted September 2, 2006 I have found some examples of this by searching the forums, but they seem to involve either a local connection from app to app, or by using consolewrite with std in/out. Both of those methods work, but do not work clean enough. The local connection method, for some reason, if app#2 has a daunting task to do, which may cause it to become temporarily unresponsive, the connection between app#1 and app#2 get's lost. The std in/out method, however does not lose a "connection", but it does cause app#1 to temp freeze as well, while app#2 is temp frozen, which I can not have. My intended usage for this is to allow app#1 to keep a heartbeat/ping to a server, and allow app#2 to run the tasks. app#1 will have app#2 do what is needed, as app#1 is supposed to report app#2's status to a server. The reason why i have it broken into 2 scripts, is to attempt to assure that the heartbeat/ping sent from app#1 to the server is at the exact same interval (or close to), and since the tasks needing to be done cause AU3 to temp freeze while it's doing it's thing, it will cause the AU3 to send the heartbeat when it recovers, which is usually longer than the needed heartbeat interval. The heartbeat interval is 15 seconds, and depending on the type of task given, the "temp freeze" that occurs, can exceed that up to 7 times. If this solution is posted somewhere else, then please let me know. I did some searching, and was able to find it. Thanks in advance. Link to comment Share on other sites More sharing options...
Azu Posted September 2, 2006 Share Posted September 2, 2006 (edited) Hi, you might want to try using AdlibEnable in your script, and in the big parts that generate lag, put some sleeps in there, so that it won't freeze up. The sleeps won't stop the pinging stuff in the AdlibEnable from running, but it will prevent the script from eating all the CPU. Edit: Example: $timer=timerinit() adlibenable("ping",50) func ping() if timerdiff($timer)>=15000 then ;do your 1337 pinging stuff here! $timer=timerinit() endif endfunc This should be accurate within 50 miliseconds. Edited September 2, 2006 by Azu Link to comment Share on other sites More sharing options...
AcidicChip Posted September 2, 2006 Author Share Posted September 2, 2006 (edited) The problem isn't sleeps in loops, which I have plenty of, and my system resources while running my scripts are optimal. The problem is that it runs WMEncoder via command line, with an stdread to get the progress. When WMEncoder first runs and initializes, as I am trying to do stdread, is when the "freeze" occurs, which is what brought me to this. I am looking into a solution using Adlib now, to see if it'll work out. Edited September 2, 2006 by AcidicChip Link to comment Share on other sites More sharing options...
Azu Posted September 2, 2006 Share Posted September 2, 2006 The problem isn't sleeps in loops, which I have plenty of, and my system resources while running my scripts are optimal. The problem is that it runs WMEncoder via command line, with an stdread to get the progress. When WMEncoder first runs and initializes, as I am trying to do stdread, is when the "freeze" occurs, which is what brought me to this.Hi, simply give WMEncoder lower priority, or AutoIt higher priority, then AutoIt will continue to run smoothly while WMEncoder does it's thing. For example processsetpriority ("WMEncoder.exes",1) This should prevent it from freezing up your AutoIt script, so you can just have it all in one. Link to comment Share on other sites More sharing options...
AcidicChip Posted September 2, 2006 Author Share Posted September 2, 2006 (edited) Using the Adlib and Timer produces the same results. As stdread is trying to read the initial command line wmencoder (as wmencoder is initializing), it causing AU3 to freeze, is also preventing the Adlib to execute. I think the problem is stdread itself, because it's stdread that is causing au3 to freeze while it's trying to read wmencoder's output. Right now I think the solution is to run the command line and append "> output.txt" to it, then run a loop to read output.txt while the process is running. In a sense it's re-creating stdread, but not tieing to the process directly (instead tieing to it's output.txt), ultimately removing the freeze. I just feel that there should be a cleaner solution to this. NOTE: Trying the loop reading of the output.txt works for what I need. I just tested it. Still would like a cleaner solution though. Edited September 2, 2006 by AcidicChip Link to comment Share on other sites More sharing options...
ChrisL Posted September 2, 2006 Share Posted September 2, 2006 (edited) Can you use peek initially, it sounds like AutoIT is waiting for some text, use peek to keep peeking until there is an output.If at any time when this function is called (except for "peeking" as described below) there are no characters to be read from the stream, the StdoutRead function will block (pause) and not return until there are characters to be read from the stream. This means that the AutoIt process will be halted, and there will be no processing of hotkeys, GUI messages, etc. until the child process writes something to the STDOUT stream.If StdoutRead is called with a third argument other than zero, StdoutRead will "peek at" the stream rather than actually reading from it, and return the characters that could be read from the stream. When run as a "peek" StdoutRead always returns immediately. Note that any characters are still present on the stream after a peek and will be returned on the next read operation. Edited September 2, 2006 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
AcidicChip Posted September 2, 2006 Author Share Posted September 2, 2006 That peek seemed to work, however, how do i know when it's done? I don't seem to be getting an @error response. Should I instead look for the process? Link to comment Share on other sites More sharing options...
ChrisL Posted September 2, 2006 Share Posted September 2, 2006 peek until line is no longer 0When called with a second argument of 0 and a third argument that directs the function to "peek", StdoutRead returns a numeric value of the number of characters that could currently be read from the stream.$line = 0While $line = 0$line = StdoutRead($foo,0,true)If @error Then ExitLoopWend;now do you proper read [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire 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