我是新的自动,并试图自动输入到一个。exe程序。这个可执行文件没有gui,是从命令窗口运行的,所以我可以使用autoit通过命令窗口发送特定于程序的输入吗?如果是这样,我该怎么做呢?
Local $engine= "C:UsersDavisDesktopChess enginestockfish32bit.exe"
Local $PID = RunWait(@ComSpec & " /k " & $engine, "", "@SW_MAXIMIZE")
;Insert code that sends program "uci" as input
这个简单的例子展示了如何与先前运行的程序通信。
; 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)
Local $engine= "C:UsersDavisDesktopChess enginestockfish32bit.exe"
Local $PID = RunWait(@ComSpec & " /k " & $engine, "", "@SW_MAXIMIZE")
$hCmd=WinGetHandle($engine)
ControlSend($hCmd, "", "", "uci" & @CR)