Sign in to follow this  
Followers 0
probedrone

command window wait for process

11 posts in this topic

If I want to run a series of tests in the dos command window, how to I tell autoit to pause until an operation is done? Not using Sleep() of course :whistle:

For example:

(AutoIt Script: Send("xxx.exe"), Send("{ENTER}"))

(Shown on cmd.exe)

C:\Documents and Settings\user name>xxx.exe

xxx.exe installing... please wait

xxx.exe finished installing

Continue AutoIt script

Share this post


Link to post
Share on other sites



it might work, but maybe make a While/WEnd loop with on top like While WinExists,

sort of like

HotKeySet("{Home}", "Install")

Func Install()
    Send("...xxx.exe")
    
    While WinExists("Installation WindowName")
        Sleep(100) 
    WEnd
    ; continue script here
EndFunc

hope it helps :whistle:

Share this post


Link to post
Share on other sites

The thing is no new windows pop up, the installation process is only shown in the command prompt window

Share this post


Link to post
Share on other sites

maybe let it somehow find the line "installation done" in dos and then proceed, wouldn't know if that could work.

good luck.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I hate double posts -__- :whistle:

Edited by omglol

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Im running different test programs and they may not always end up with the same "installation done" line. Anyway AutoIt cant detect lines from a dos window. Is there a way to check the process of a window and when it is done? Im not sure how to use the ProcessWait() command in my script tho. Any help would be nice.

Edited by probedrone

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

HotKeySet("{Home}", "Install")

Func Install()
    Send("...xxx.exe")
   
    While ProcessExists("Installation")
        Sleep(100)
    WEnd
    ; continue script here
EndFunc

??? just giving some ideas i wouldn't know if it works, so let me know :whistle:

Edit: nasty typo

Edited by omglol

Share this post


Link to post
Share on other sites

If you're using 3.2 you may wish to take a look at the StdOutRead() function.


Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

If you're using 3.2 you may wish to take a look at the StdOutRead() function.

Yea Im kinda newbie at AutoIt. I got beta but cant figure out how stdoutread can help in my program, any advice (or piece of code) would be great.

Also, omglol, it would be best if your solution can work, but I dont know what "Installation" is. Am I supposed to fill in the name of my own program? How do I do that if the process is not shown?

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Suppose you have this batch file that puts stuff up on the screen periodically:

@echo off
set _wf=%TEMP%\~wait.tmp
echo wscript.sleep WScript.Arguments(0)>%_wf%

echo Starting_1
echo Here is where you do something
cscript %_wf% 5000 //NOLOGO //E:VBSCRIPT
echo Done_1
cscript %_wf% 5000 //NOLOGO //E:VBSCRIPT

echo Starting_2
echo Here is where you do something else
cscript %_wf% 7000 //NOLOGO //E:VBSCRIPT
echo Done_2

cscript %_wf% 5000 //NOLOGO //E:VBSCRIPT
del %_wf%
set _wf=

You can use something like this to tell what is going on:

SplashTextOn("MyProgress", "Now installing", 300, 100)
$CHILDDOS = Run(@ComSpec & ' /c "' & @ScriptDir & '\test.bat"', @ScriptDir, @SW_MINIMIZE, 2)

While 1
    $Status = StdoutRead($CHILDDOS)
    If @error Then ExitLoop
    Select
        Case StringInStr($Status, "Starting_1")
            ControlSetText("MyProgress", "", "Static1", "Now installing program 1")
        Case StringInStr($Status, "Done_1")
            ControlSetText("MyProgress", "", "Static1", "Done install 1")
        Case StringInStr($Status, "Starting_2")
            ControlSetText("MyProgress", "", "Static1", "Now installing program 2")
        Case StringInStr($Status, "Done_2")
            ControlSetText("MyProgress", "", "Static1", "Done install 2")
    EndSelect
    Sleep(10)
WEnd

SplashOff()
Edited by bluebearr

BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

Yea Im kinda newbie at AutoIt. I got beta but cant figure out how stdoutread can help in my program, any advice (or piece of code) would be great.

Also, omglol, it would be best if your solution can work, but I dont know what "Installation" is. Am I supposed to fill in the name of my own program? How do I do that if the process is not shown?

I wouldn't know for sure if it would work in the first place, you'd have to check that out by yourself...

anyways i'm sorry that i didn't clearafy that when i posted the piece of code, but when you type ProcessExists( it'll show you to put the name of the process in there, wich will be in the task manager when you've started the installation at processes i think, never worked with it myself,

again it's up to you to test it out :whistle:

good luck.

Share this post


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
Sign in to follow this  
Followers 0