开发者

automate a windows command line utility with a batch file - send keystrokes to std input after utility starts

I have a command line utility which opens a serial connection specified by args sent in (duh) the command line. After the utility starts, I can type into the std input to send strings to the port to which I am connected. What I would like to do is start the utility with a batch file (easy enough), then automate the keystrokes I wish to send. I am having no luck on my own and need some expert advice.

I'll give a more specific example: I start teraterm.exe (opensource serial communication utility) in a batch file with this line: "call serialterm com5 115200 ascii yes" Then, I can type "Hello World " and receive the response from the open port. I want the next line in my batch file to send "Hello World " for me, so that I can issue other string commands by listing them in the 开发者_JS百科batch file.

Help is greatly appreciated!

-Matt


To automate this, a batch file is not the perfect solution(And I'm one of the batch fanatics), as it is not possible to send keystrokes.
You could switch to JScript/VBscript (possible to send keystrokes, but it's tricky and not very reliable).

But I would recommend a tool like AutoIt, as it can do such things very good.


Put the commands in another file and use the < redirection operator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜