Jump to content

send text to dos console window


 Share

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...