Jump to content

Using Command Prompt

Recommended Posts

Guest p.boutonnet


With Notepad, it works:

ControlSend("Untitled", "", "Edit1", "This is a line of text in the Notepad window")

My purpose is to use the same script for CMD.exe instead of Notepad.

I try:

ControlSend ( "Command Prompt", "","????", "This is a command line in the CMD.exe window")

I don't find a "ClassName" to substitute to the "????". Is it possible?

If not, an another function to use?

I can not use the Send function because my CMD.exe window is not always the active window during the process.

Thank you very much,


Link to post
Share on other sites
  • Moderators

Have you tried Run(@ComSpec, etc..., etc...)?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to post
Share on other sites

process? A solution maybe given if the task was known. The command console is not a standard win32 application like notepad, so you would expect different results to happen. It also has not controls, so ControlSend, if works ok, is a blind attempt. If you want to pursue with a send function, then ControlSendPlus may help. It is in the scripts n scraps forum if searched.

Other alternatives could be a dos batch file or to use direct Runwait commands to @ComSpec.

Link to post
Share on other sites
Guest p.boutonnet

I try precisely this:

(Notice I am beginner :whistle: ..



WinWaitActive (@COMSPEC)

Send("title MyCMDWindow{ENTER}")

send ("cd C:\MyFolder{ENTER}")

send ("ftp{ENTER}")






Send ("bin{ENTER}")

Send ("prompt{ENTER}")

Send ("mget *.mat{ENTER}")

Send ("y{ENTER}")

Send ("quit{ENTER}")

send("FOR %f IN (""*.mat"") DO ( MyEXE.exe -c %f ){ENTER}")

WinWaitClose ("MyEXE.exe")

Send ("exit{ENTER}")


While the execution of the script above, the PC user can work on other things and "MyCMDWindow" is not the currently active windows.

So the Send("") command does not achieve the work.

I think about ControlSend, but you confirm it is not possible.

Runwait is not adapted too.

I looking for the ControlSendPlus function...

Perhaps a completely different way to program my script above? :dance:

Thank you very much

Link to post
Share on other sites

Since your script runs pretty quickly before you get to...

send("FOR %f IN (""*.mat"") DO ( MyEXE.exe -c %f ){ENTER}")

...why not minimize the window(s) when you get to this point, and your WinWaitClose() function will still work to close the "MyEXE" program and then exit.
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...