Jump to content

use controlsend with console


CFLam
 Share

Recommended Posts

Hello all,

I am using AutoIt 3.2.2.0 and I use it to automate one of my DOS application. It work like magic and now I would like to automate the application in 'background' mode. So I change my script from send to controlsend. But I find that ControlSend seems not work with console:

ControlSend("cmd.exe","","","d:{Enter}")

the d: display on the SciTE instead of the console window, seems that ControlSend can't detect it, I try the following as well:

AutoItSetOption("WinTitleMatchMode",-4)

ControlSend("classname=ConsoleWindowClass","","","d:{Enter}")

also not work.

anyone has a clue on it ?

Also, how can I detect output from DOS application ? my app will display "Finished" in the console after finish the task, currently I am using:

send ("!{space}es{enter}")

and check with clipget() to see if the word "finished" appear, is there any other method to deal with it ? ControlSend support window context menu ?

Thanks.

Regds

LAM Chi-fung

Link to comment
Share on other sites

  • Moderators

ControlSendPlus() <<--- Do a search for it.

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 comment
Share on other sites

I try controlsendplus but still not work...

#include "ControlSendPlus.au3"

AutoItSetOption("WinTitleMatchMode",-2)

AutoItSetOption("SendKeyDelay", 40)

Run("cmd", "d:")

sleep(3000)

ControlSendPlus("cmd.exe","","","dir{enter}", 0)

if the console is active, this work fine, but if it was minimize, the console cannot receive the "dir".

Regds

LAM Chi-fung

Link to comment
Share on other sites

It works, but the purpose of ControlSend/ControlSendPlus is send to non-active windows...

I try this also not work:

#include "ControlSendPlus.au3"

AutoItSetOption("WinTitleMatchMode",-2)

AutoItSetOption("SendKeyDelay", 40)

Run("cmd", "d:")

WinWaitActive ("cmd.exe")

WinSetState("cmd.exe","",@SW_MINIMIZE )

ControlSendPlus("cmd.exe","","","dir{enter}", 0)

Link to comment
Share on other sites

Try changing it to

AutoItSetOption("WinTitleMatchMode",-2)
AutoItSetOption("SendKeyDelay", 40)
Run("cmd", "d:", @SW_MINIMIZE)
WinWaitActive ("cmd.exe")
ControlSendPlus("cmd.exe","","","dir{enter}", 0)

That worked for me... :)

EDIT: Error in my code... :D

Edited by bert
Link to comment
Share on other sites

Hello,

I try this

$mypid=run("C:\WINDOWS\System32\cmd.exe","d:\myapp",@SW_MAXIMIZE ,$STDOUT_CHILD)

controlsend("cmd.exe","","","myapp{enter}")

$line = StdoutRead($mypid)

and the console become blank (black)...... my script right ?

Regds

LAM Chi-fung

Link to comment
Share on other sites

Hello,

I try 3.2.0.1 and the ControlSend work, however, even with ControlSendPlus, I still not able to access the context menu of command prompt (console)... any hint ? Thanks.

Regds

LAM Chi-fung

context menu of the command prompt... How did you try to activate that with ControlSend(). Please post code.

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

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...