ijourneaux Posted June 3, 2010 Share Posted June 3, 2010 I am trying to send commands to a console application. The AutoIt Window Info gives the window title (Octave)and the the window class (ConsoleWindowClass). I tried WinActivate('Octave') ConsoleWrite ( 'data' ) That moved the window to the forground but the string 'data' did not appear in the console. Is there a way to accomplish this? Link to comment Share on other sites More sharing options...
UEZ Posted June 3, 2010 Share Posted June 3, 2010 I think StdinWrite may help you! Search in help file for an example.BR,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
ijourneaux Posted June 4, 2010 Author Share Posted June 4, 2010 I think StdinWrite may help you! Search in help file for an example. BR, UEZ I tried #include <Constants.au3> $ProcessID = Run('C:\Octave\3.2.4_gcc-4.4.0\bin\Octave.exe', '', @SW_MAXIMIZE) sleep(40000) $Handle = WinActivate('C:\Octave\3.2.4_gcc-4.4.0\bin\Octave.exe') StdinWrite($ProcessID, "rat" & @CRLF) Unfortunately no luck. Link to comment Share on other sites More sharing options...
bo8ster Posted June 4, 2010 Share Posted June 4, 2010 Have a look at Log ConsoleWrite output in Scite in my sig. Let me know if you have any questions. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
ijourneaux Posted June 4, 2010 Author Share Posted June 4, 2010 Have a look at Log ConsoleWrite output in Scite in my sig.Let me know if you have any questions.I took a look at your scripts. I can get them to work but all of my attempts to send strings to the application I am trying to interact with (Octave) have failed. Octave in a math application compiled with the MinGW compiler. I have no ability to modify it at all. I am not sure what else I can try.I aprecaite you taking a stab at it though.Take Link to comment Share on other sites More sharing options...
bo8ster Posted June 8, 2010 Share Posted June 8, 2010 Is Octave looking at the stdout? What is the code within Octave that receives the message? Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
ResNullius Posted June 8, 2010 Share Posted June 8, 2010 I am trying to send commands to a console application. The AutoIt Window Info gives the window title (Octave)and the the window class (ConsoleWindowClass). I tried WinActivate('Octave') ConsoleWrite ( 'data' ) That moved the window to the forground but the string 'data' did not appear in the console. Is there a way to accomplish this? Two methods that work for me: First, using ControlSend to a visible Octave window $sProcess = "C:\Octave\3.2.4_gcc-4.4.0\bin\octave.exe" Run($sProcess, "C:\Octave\3.2.4_gcc-4.4.0\bin", @SW_SHOW) WinWait($sProcess) ControlSend($sProcess,"","","(8+4)/2" & @CRLF, 1) Second, using StdInWrite to a hidden Octave Window #include <Constants.au3> $pOctave = Run("C:\Octave\3.2.4_gcc-4.4.0\bin\octave.exe", "C:\Octave\3.2.4_gcc-4.4.0\bin", @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD) StdinWrite($pOctave, "(8+4)/2" & @CRLF) StdinWrite($pOctave) Local $data While True $data &= StdoutRead($pOctave) If @error Then ExitLoop Sleep(25) WEnd $data = StringRegExpReplace($data, "(?s)(.*)(ans\s=.*)", "$2") MsgBox(0, "Answer", $data) Link to comment Share on other sites More sharing options...
ijourneaux Posted July 23, 2010 Author Share Posted July 23, 2010 Two methods that work for me: First, using ControlSend to a visible Octave window $sProcess = "C:\Octave\3.2.4_gcc-4.4.0\bin\octave.exe" Run($sProcess, "C:\Octave\3.2.4_gcc-4.4.0\bin", @SW_SHOW) WinWait($sProcess) ControlSend($sProcess,"","","(8+4)/2" & @CRLF, 1) Second, using StdInWrite to a hidden Octave Window #include <Constants.au3> $pOctave = Run("C:\Octave\3.2.4_gcc-4.4.0\bin\octave.exe", "C:\Octave\3.2.4_gcc-4.4.0\bin", @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD) StdinWrite($pOctave, "(8+4)/2" & @CRLF) StdinWrite($pOctave) Local $data While True $data &= StdoutRead($pOctave) If @error Then ExitLoop Sleep(25) WEnd $data = StringRegExpReplace($data, "(?s)(.*)(ans\s=.*)", "$2") MsgBox(0, "Answer", $data) Thanks for the examples. I have confirmed that both of these work for. Regarding the second example, I was wondering how the Octave window gets closed. It has something to do with the $STDIN_CHILD + $STDOUT_CHILD but I am not sure I understand why. When the script is executed, Link to comment Share on other sites More sharing options...
bo8ster Posted July 25, 2010 Share Posted July 25, 2010 Look up Run in the help file, it will explain what they are. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
ijourneaux Posted July 26, 2010 Author Share Posted July 26, 2010 Look up Run in the help file, it will explain what they are.Will do. Thanks Link to comment Share on other sites More sharing options...
MasonMill Posted July 26, 2010 Share Posted July 26, 2010 Bo8ster, when i run your console capture script it doesnt stay in the loop. What am i doing wrong? I have a script i would like to monitor but i cant get your script to run long enough. Thanks! Link to comment Share on other sites More sharing options...
bo8ster Posted July 26, 2010 Share Posted July 26, 2010 Bo8ster, when i run your console capture script it doesnt stay in the loop. What am i doing wrong? I have a script i would like to monitor but i cant get your script to run long enough. Thanks!@MasonMill - its not expected to stay in the loop. When script one finishes, script two will stop (controlled by the if statement).To run your script, replace "C:\<....>\workspace.au3" with the full path of your script in the second script. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
ijourneaux Posted August 3, 2010 Author Share Posted August 3, 2010 I am using the controlsend approach you described above. How do I pause the AutoIt script until Octave has finished processing? Link to comment Share on other sites More sharing options...
ijourneaux Posted August 3, 2010 Author Share Posted August 3, 2010 Is there a way to pause the autoit script until the command window application (in this case Octave) has finished processing? Link to comment Share on other sites More sharing options...
bo8ster Posted August 4, 2010 Share Posted August 4, 2010 ProcessWaitClose($foo) is used to wait till the process finishes. The program should stop in the while loop till the processing is done. I suggest you add #AutoIt3Wrapper_run_debug_mode=Y and some additional ConsoleWrites in my second script to see what is going on. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] 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