Reputation: 21
I am new to autoit and am trying to automate the input to an .exe program. This executable does not have a gui and is run from the command window so can I use autoit to send the program specific input through the command window? If so how can I go about doing this?
Local $engine= "C:\Users\Davis\Desktop\Chess engine\stockfish32bit.exe"
Local $PID = RunWait(@ComSpec & " /k " & $engine, "", "@SW_MAXIMIZE")
;Insert code that sends program "uci" as input
Upvotes: 0
Views: 3411
Reputation: 2946
This simple example shows how you can communicate with previously ran program.
; Demonstrates the use of StdinWrite()
#include <Constants.au3>
Local $foo = Run("sort.exe", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
; Write string to be sorted to child sort.exe's STDIN
StdinWrite($foo, "rat" & @CRLF & "cat" & @CRLF & "bat" & @CRLF)
; Calling with no 2nd arg closes stream
StdinWrite($foo)
; Read from child's STDOUT and show
Local $data
While True
$data &= StdoutRead($foo)
If @error Then ExitLoop
Sleep(25)
WEnd
MsgBox(0, "Debug", $data)
Upvotes: 2
Reputation: 21
Local $engine= "C:\Users\Davis\Desktop\Chess engine\stockfish32bit.exe"
Local $PID = RunWait(@ComSpec & " /k " & $engine, "", "@SW_MAXIMIZE")
$hCmd=WinGetHandle($engine)
ControlSend($hCmd, "", "", "uci" & @CR)
Upvotes: 1