Sign in to follow this  
Followers 0
anyday

send text to dos console window

7 posts in this topic

i have a simple question, ive searched threw the forums a bit but have not seen what im looking for.

i have a script that runs a dos command, using just Run("filename.exe"), it will run the program just fine, but i need to send a keystroke the the dos console window that opens. Ive tried send("{SPACE}") also tried ControlSend with no luck.

Anyone have any advice on howto send a keystroke to a dos command prompt?

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

i have a simple question, ive searched threw the forums a bit but have not seen what im looking for.

i have a script that runs a dos command, using just Run("filename.exe"), it will run the program just fine, but i need to send a keystroke the the dos console window that opens. Ive tried send("{SPACE}") also tried ControlSend with no luck.

Anyone have any advice on howto send a keystroke to a dos command prompt?

Thanks

ControlSend() doesn't work for DOS, try Send().

Example:

Run('cmd',@SystemDir,@SW_HIDE)
WinWait(@SystemDir & "\cmd.exe")
WinActivate(@SystemDir & "\cmd.exe")
Send('ver' & @CRLF)
WinSetState(@SystemDir & "\cmd.exe","",@SW_SHOW)
Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Ive been trying send() it has no effect

Share this post


Link to post
Share on other sites

Ive been trying send() it has no effect

Just look my edit in preview post (an example).


When the words fail... music speaks

Share this post


Link to post
Share on other sites

thanks for the help guys, i tried your example Andreik with no success, but everything working good now with the Opt("WinTitleMatchMode", 2)

Share this post


Link to post
Share on other sites

thanks for the help guys, i tried your example Andreik with no success, but everything working good now with the Opt("WinTitleMatchMode", 2)

With WinTitleMatchMode is more delicate problem. If you have a window that contains the word 'cmd' is not too good.

To avoid this problem, use only started WinTitleMatchMode, then you can give DOS window a unique name.

AutoItSetOption("WinTitleMatchMode",2)
Run('cmd.exe',@SystemDir,@SW_HIDE)
WinWait("cmd.exe")
WinActivate("cmd.exe")
Send('TITLE MyCMD' & @CRLF)
WinSetState('MyCMD','',@SW_SHOW)

When the words fail... music speaks

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0