narayanjr Posted July 7, 2007 Share Posted July 7, 2007 How would i read text from a cmd window? I need to get the ip address of a game that im in and using netstat -n works but i want to get it out of the console and write it to a notepad WinGetText returns a blank string and i dont understand the ConsoleRead() function Thanks Link to comment Share on other sites More sharing options...
ChrisL Posted July 7, 2007 Share Posted July 7, 2007 look at StdOutRead in the help file [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...
narayanjr Posted July 7, 2007 Author Share Posted July 7, 2007 (edited) that works fine but now i have a new problem #include <Constants.au3> $pid = Run(@ComSpec & " /c " & 'netstat -n', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $pos = StringInStr(StdoutRead($pid,9000), ":4000") $periodpos = StringInStr(StdoutRead($pid,9000), ".",0,78) WinWaitActive("Untitled") Send($pos) Send("{ENTER}") Send($periodpos) While 1 $line = StdoutRead($pid) If @error Then ExitLoop Send($line) WendoÝ÷ Ù«¢+ØÀÌØíÁ½ÌôMÑÉ¥¹%¹MÑÈ¡MѽÕÑI ÀÌØíÁ¥°äÀÀÀ¤°ÅÕ½ÐìèÐÀÀÀÅÕ½Ðì¤(ÀÌØíÁÉ¥½Á½ÌôMÑÉ¥¹%¹MÑÈ¡MѽÕÑI ÀÌØíÁ¥°äÀÀÀ¤°ÅÕ½Ðì¸ÅÕ½Ðì°À°Üà¤oÝ÷ Û^+¬zØb²+kzÛ«Í4ªê-ªê-jëh×6$pos = StringInStr(StdoutRead($pid,9000,true), ":4000") $periodpos = StringInStr(StdoutRead($pid,9000,true), ".",0,78) what am i doing wrong? Edited July 7, 2007 by narayanjr Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 7, 2007 Share Posted July 7, 2007 that works fine but now i have a new problem what am i doing wrong? The StdOutRead() runs microseconds after the Run(), and there isn't anything there yet. You need a loop to catch all the output before you start to process it: #include <Constants.au3> $Output = "" $pid = Run(@ComSpec & " /c " & 'netstat -n', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Do $Output &= StdoutRead($pid) Until @error MsgBox(64, "netstat -n", $Output) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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