t0ddie Posted June 18, 2005 Share Posted June 18, 2005 i need to know how to get data from a hidden command prompt window, and place it into a variable. Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
w0uter Posted June 18, 2005 Share Posted June 18, 2005 i need to know how to get data from a hidden command prompt window, and place it into a variable.<{POST_SNAPBACK}>STD function's or use "command > C:\path\file.txt" My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
t0ddie Posted June 18, 2005 Author Share Posted June 18, 2005 not exactly sure where to look for examples, could you provide one? Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted June 18, 2005 Share Posted June 18, 2005 StdOutRead() or when using the run command, just do *command* > C:\file.txt Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
w0uter Posted June 18, 2005 Share Posted June 18, 2005 (edited) *done by head maby the \ needs to be opposite* Run(@comspec & ' \c dir > "C:\file.txt"') will output the dir command to C:\file.txt for STD $v_NETSTAT = Run(@SystemDir & '\netstat.exe', @SystemDir, @SW_HIDE, 2) $v_NETSTAT = StdoutRead ($v_NETSTAT) for example Edited June 18, 2005 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
t0ddie Posted June 19, 2005 Author Share Posted June 19, 2005 (edited) heres the thing. im running another program, that makes the command prompt window. #include <Constants.au3> $dir = c\:program files\game $foo = Run($dir & "\showinstalledkey.exe","", $STDERR_CHILD + $STDOUT_CHILD) sleep(10000) While 1 $line = StdoutRead($foo) If @error = -1 Then ExitLoop MsgBox(0, "STDOUT read:", $line) Wend While 1 $line = StderrRead($foo) If @error = -1 Then ExitLoop MsgBox(0, "STDERR read:", $line) Wend MsgBox(0, "Debug", "Exiting...") and this dont work. it wont read anything in the window. the window title is not c:/windows/system32/cmd.exe its the directory of the program and the program name. im not running the prompt myself, im just trying to read data from a prompt another program opened. edit: i took the @sw_hide out of the code cause i was trying to debug it and i wanted to make sure the program was opening. and for some reason as well, its creating a .txt file on my desktop, which is where i run the script from. Edited June 19, 2005 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
DaveF Posted June 19, 2005 Share Posted June 19, 2005 (edited) The STD I/O parameter is the 4th parameter to Run(), not the third:$foo = Run($dir & "\showinstalledkey.exe","", $STDERR_CHILD + $STDOUT_CHILD)...should be...$foo = Run($dir & "\showinstalledkey.exe",$dir ,@SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Edited June 19, 2005 by DaveF Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines. Link to comment Share on other sites More sharing options...
t0ddie Posted June 19, 2005 Author Share Posted June 19, 2005 (edited) hitting self over head.. yeah i figured that out before i read this post, but your right. and i kinda got something working BUT im having a serious problem though, i need to get lines 9 and 10 from the command prompt. heres what the code looks like that im using. #include <GuiConstants.au3> #include <GuiConstants.au3> #include <Constants.au3> $dir = c:\ GuiCreate("GUI") $hEdit = GuiCtrlCreateEdit("", 5, 5, 300, ) $hInput = GUICtrlCreateInput("", 5,220) GuiSetState() $PID = Run($dir & "\showinstalledkey.exe", $dir, @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD) $origkey = FileOpen(@ScriptDir & "\key.txt",1) While 1 ; Check how many characters are waiting to be read $data = StdoutRead($PID, 0, 1) If $data Then While 1 $line = StdoutRead($PID) If @error = -1 Then ExitLoop GUICtrlSetData($hEdit, $line, 1) FileWrite($origkey,$line) Wend EndIf $nMsg = GuiGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE ProcessClose($PID) Exit EndSelect WEnd im having MULTIPLE problems i have to use sw_show and cant use hide or it wont work. i run from the script the program that brings up the command prompt. its now bringing up a BLANK command prompt unlike when i start the program manually it shows the data in the command prompt.. i close the command prompt and only THEN does it show the data in the gui and the text file is blank. i glose the gui and finally its in the .txt file i tried a crappy workaround to automate this all but none are working. so my goal is to hide the window, not use a gui at all. and just run my script. then it will close itself when finished and ill be left with a .txt file containing line 9 from the command prompt, and line 10 from the command prompt. this is really frustrating me! Edited June 19, 2005 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
jefhal Posted June 20, 2005 Share Posted June 20, 2005 hitting self over head.. yeah i figured that out before i read this post, but your right.and i kinda got something working BUTim having a serious problem though,i need to get lines 9 and 10 from the command prompt.heres what the code looks like that im using.#include <GuiConstants.au3> #include <GuiConstants.au3> #include <Constants.au3> $dir = c:\ GuiCreate("GUI") $hEdit = GuiCtrlCreateEdit("", 5, 5, 300, ) $hInput = GUICtrlCreateInput("", 5,220) GuiSetState() $PID = Run($dir & "\showinstalledkey.exe", $dir, @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD) $origkey = FileOpen(@ScriptDir & "\key.txt",1) While 1 ; Check how many characters are waiting to be read $data = StdoutRead($PID, 0, 1) If $data Then While 1 $line = StdoutRead($PID) If @error = -1 Then ExitLoop GUICtrlSetData($hEdit, $line, 1) FileWrite($origkey,$line) Wend EndIf $nMsg = GuiGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE ProcessClose($PID) Exit EndSelect WEndim having MULTIPLE problemsi have to use sw_show and cant use hide or it wont work.i run from the script the program that brings up the command prompt. its now bringing up a BLANK command prompt unlike when i start the program manually it shows the data in the command prompt.. i close the command prompt and only THEN does it show the data in the gui and the text file is blank.i glose the gui and finally its in the .txt filei tried a crappy workaround to automate this all but none are working.so my goal is to hide the window, not use a gui at all. and just run my script.then it will close itself when finished and ill be left with a .txt file containing line 9 from the command prompt, and line 10 from the command prompt.this is really frustrating me!<{POST_SNAPBACK}>This is really inelegant, but it works with a Win2K command prompt window. It calls the built-in SelectAllCopy function and puts the clipboard into $var. You can then look for stringinstr to find what you need. May not work with your hidden command window though:WinActivate("Command Prompt") send ("!{space}es") send("{enter}") $var = ClipGet() MsgBox(0,"",$var)Please provide feedback if I did not submit this properly. :"> ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
t0ddie Posted June 20, 2005 Author Share Posted June 20, 2005 i would rather use something more reliable, and also work on more windows version. but thanks for the response Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. 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