IVIarco Posted May 12, 2010 Posted May 12, 2010 Hi all I have another question... Everybody in his life played (or once a time got interested) with the command promt or software written in wise C/C++...aaaaah is nice using a software without a interface,where you use just keyboard instead of mouse...but,if somebody need to use a program in c/c++ and get scaried to see a consolle...how can help him/her(mmm...her )? The question is:how i can get in the GUI the output of a command promt or similar?Or send commands with the gui and see command promt in action directly in the gui?
hawky358 Posted May 12, 2010 Posted May 12, 2010 Look at the help for Run, specifically look at the options: $STDIN_CHILD, $STDOUT_CHILD and similar. They allow you to capture streams from the run. I may write some sample code a little later if someone else hasn't yet, but this should get you on the right track.
wolf9228 Posted May 12, 2010 Posted May 12, 2010 On 5/12/2010 at 5:51 PM, 'IVIarco said: Hi all I have another question... Everybody in his life played (or once a time got interested) with the command promt or software written in wise C/C++...aaaaah is nice using a software without a interface,where you use just keyboard instead of mouse...but,if somebody need to use a program in c/c++ and get scaried to see a consolle...how can help him/her(mmm...her )? The question is:how i can get in the GUI the output of a command promt or similar?Or send commands with the gui and see command promt in action directly in the gui? Running Scripts http://www.autoitscript.com/autoit3/docs/intro/running.htm Command Line Parameters The special array $CmdLine is initialized with the command line parameters passed in to your AutoIt script. Note the scriptname is not classed as a parameter; get this information with @ScriptName instead. A parameter that contains spaces must be surrounded by "double quotes". Compiled scripts accept command line parameters in the same way. $CmdLine[0] is number of parameters $CmdLine[1] is param 1 (after the script name) $CmdLine[2] is param 2 etc ... $CmdLine[$CmdLine[0]] is one way to get the last parameter... Function Reference StderrRead http://www.autoitscript.com/autoit3/docs/functions/StderrRead.htm Function Reference StdinWrite http://www.autoitscript.com/autoit3/docs/functions/StdinWrite.htm Function Reference StdoutRead http://www.autoitscript.com/autoit3/docs/functions/StdoutRead.htm صرح السماء كان هنا
IVIarco Posted May 12, 2010 Author Posted May 12, 2010 Very good,now I need 2 find the function to display in the GUI the "hidden side of the cmd.exe"(oooh awesome) and then I (try to...)post an example code.
hawky358 Posted May 13, 2010 Posted May 13, 2010 On 5/12/2010 at 10:59 PM, 'IVIarco said: Very good,now I need 2 find the function to display in the GUI the "hidden side of the cmd.exe"(oooh awesome) Like I said, you use run() with $STDIN_CHILD, $STDOUT_CHILD Here you go, just take note that I used enter as the send hotkey here and hotkeys are global even when the window is not focused, you may want to use another way but I just used it for the example. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <Constants.au3> HotKeySet("{ENTER}","sendtocmd") GUICreate("Promt GUI DEMO") $in = GUICtrlCreateInput("",10,300,300) $out = GUICtrlCreateEdit("",10,10,350,250, $ES_READONLY+$WS_VSCROLL) GUICtrlSetBkColor(-1,0x000000) GUICtrlSetColor(-1,0xffffff) GUISetState() $cmd = Run("cmd","",@SW_HIDE, $STDIN_CHILD+$STDOUT_CHILD ) local $disp,$dispold while 1 $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE Then ProcessClose("cmd.exe") Exit EndIf sleep(10) $disp &= StdoutRead($cmd) if $disp <> $dispold Then ;prevent refresh flash $dispold = $disp GUICtrlSetData($out,$disp,1) If @error Then ExitLoop EndIf WEnd func sendtocmd() StdinWrite($cmd, GUICtrlRead($in) & @CRLF) GUICtrlSetData($in,"") EndFunc
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