Jump to content

How to know when a Command Prompt paste has finished?

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 post
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 post
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
    Local $StatusText = ControlGetText("[CLASS:ConsoleWindowClass]", "", "")
    If $StatusText = "Command Prompt" Then
        $bTimerStatus = 1 ;show that time hadn't expired
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 post
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 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.

  • Similar Content

    • By Fortitude
      I have made a program, that opens a folder, and then store the path ("C:\programFiles\etc") in a variable.
      Then i need to open the command panel as administrator, and write  in the stored path, and some other text.

      Can i somehow instantly copypaste the text i needed, instead of writing in the command panel with the Send commands?
      #RequireAdmin #include <MsgBoxConstants.au3> Global Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Global $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "Nem választottál ki mappát!") Exit EndIf Global $Tiff_path = $sFileSelectFolder & "\TiffChecker_2_32" FileCopy( "C:\TiffChecker_2_32.exe" , $sFileSelectFolder) $CMD = $Tiff_path & " " & $sFileSelectFolder & " /s/d" Run("C:\WINDOWS\system32\cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send($CMD) Sleep(1000) Send("{ENTER}") sleep(1000) MsgBox(0,"Press OK", "Press OK to continue") FileCopy("C:\Tiffchecker.txt", $sFileSelectFolder) Also, how do i close the command panel, when the program is finished? (usually its under 1 second, so after the send i just put a Sleep function there)
    • By FrancescoDiMuro
      Good morning AutoIt community!
      Today, I'm here to ask you if you know how to run an .exe from cmd.exe ( Command Prompt )...
      My intention is to read a .ini file where I store an information that has to be included in the shell, and run an .exe with that information...
      I'll give you an example
      Local $aFileCartellaAuditCopy = _FileListToArray($sPercorsoAuditCopy, "*.txt") If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la lettura della lista dei file nella directory" & @CRLF & $sPercorsoAuditCopy & @CRLF & "Errore: " & @error) Return False Else Local $iPID = Run("cmd.exe" & ' /k "C:\Users\Portatile-60\Desktop\HmiCheckLogIntegrity.exe" "C:\Users\Portatile-60\Desktop\AuditTrailDosaggio0_20170327_151335_DOSAGGIO_PW_01.txt"') ; & " /k " & '"' & $sHmiCheckLogIntegrity & '"' & " " & '"' & $sPercorsoAuditCopy & "\" & $aFileCartellaAuditCopy[1] & '"', "", @SW_SHOW, $STDOUT_CHILD) Return True EndIf This code is in a function, that returns False if it can retrive at least a file from the path stored in the .ini file...
      I would like to run the Command Prompt with the .exe and with a parameter of that .exe, but it seems to not work properly.

      Could please anyone tell me why?

    • By Tumulus
      I need to create a new administrator account on a number of computers, so figured I would make a script to do it. 
      You can only add/modify admin profile from an elevated command prompt (administrator command prompt). So I tried writing that into my short script. I thought that my "RunAs" command below would do the trick, but it opens a standard cmd window through the admin profile.
      Anyone able to tell me how to get it to open the elevated cmd?
      RunAs("administrator",@ComputerName,$sAdminPassword,0,@ComSpec) Sleep (500) Send("net user /ADD " & $sUsername & " " & $sPassword) Send("{ENTER}") Send("Y") Send("{ENTER}") Send("net user " & $sUsername & " /passwordchg:no") Send("{ENTER}") Send("net localGroup administrators " & $sUsername & " /ADD") Send("{ENTER}") WinClose("C:\Windows\system32\cmd.exe")  
    • By lrstndm
      Hi all,
      I am working on a application with a GUI and command prompt in 1.
      Currently my code looks this simple >
      #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_Change2CUI=y #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 615, 437, 192, 124) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd But when I compile this and run the compiled version there is also a command prompt shown. But I don't want this.
      Besides that, I also want it to be possible when I run my script from the command prompt, the program will give feedback in the command prompt where it was started from. With the setup above. This is possible with the ConsoleWrite command. 
      Is it possible to hide the command prompt one way or another when I start the GUI? Or do I have to change my script?
      I hope someone can help me.
    • By ur
      When I execute any batch command then it is prompting a command window for 1 second till the command executes with the below command.
      $CMD = "net localgroup administrators domainaname\usename /add"
      RunWait(@ComSpec & " /q /c " & $CMD)
      Is there any way to exeute the command without showing the window.
  • Create New...