Jump to content

How to know when a Command Prompt paste has finished?


Tippex
 Share

Recommended Posts

How can I detect when a Command Prompt window has returned to idle with prompt for the next command please?

For example, after a large paste:

                        ControlClick("[CLASS:ConsoleWindowClass]", "", "", "right")
                        ControlSend("[CLASS:ConsoleWindowClass]", "", "", "p") 

a large paste may be something like copying some large files which may go on for some time after the paste command has been given.

 

 

 

Link to comment
Share on other sites

  • Moderators

@Tippex probably an easier path would be to determine why you need the command prompt at all. How about an explanation of what you're trying to accomplish? Most anything you would do at a command prompt can be done natively in AutoIt, with logging/output/etc., and would save you the headache you're experiencing now.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Thank you for your response, most appreciated.

I'm using a command prompt for both the confidence of visually monitoring that the program is "on the rails" (doing what it is supposed to do) and also to provide a way to recover an unexpected situation in case of some failure (where I can step in whilst the program is paused, correct, then let it resume).

Experimenting, I have this possible solution:

Local $hTimer = TimerInit()
Local $bTimerStatus = 0
Do
    Local $StatusText = ControlGetText("[CLASS:ConsoleWindowClass]", "", "")
    If $StatusText = "Command Prompt" Then
        $bTimerStatus = 1 ;show that time hadn't expired
        ExitLoop
    Else
        Sleep(500)
    EndIf
Until TimerDiff($hTimer) > 10000

I am finding that when it is busy, the command which is keeping it busy will appear hyphenated and appended to "Command Prompt" for a return of its ControlGetText().

For example, if it is busy because it is doing a DOS command "Pause" then (in the code above) $StatusText would be "Command Prompt - Pause".

If it is idle, then $StatusText would just be "Command Prompt".

I haven't checked yet if this would give an "idle" in between a set of commands in a single paste ... I hope not :)

Link to comment
Share on other sites

  • Moderators

Again, anything Command Prompt can do AutoIt can do, including giving you visual feedback on your script. Rather than trying to use one scripting language to automate another, why not let us know what you're doing in the Command Prompt so we can give suggestions on how to do it better natively?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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

×
×
  • Create New...