Jump to content

Reading percent from makecab console


igorm
 Share

Recommended Posts

Hi,

I'm trying to read percentage from console window of makecab for updating my progress bar, but I'm having problems with it. I'm using following code but it wont work. I can get text return from console but I can't extract percentage numbers.

#include <Constants.au3>
$progressbar2 = ProgressOn("Test", "Please wait")
$runcheck=Run(""""&@SystemDir&"\makecab.exe"&""""&" /f ""D:\offxp\OFFICE1.ddf""", "D:\offxp", "", $STDOUT_CHILD)
While ProcessExists($runcheck)
        $readtextfromconsole = StdoutRead($runcheck)
        If (StringRegExp($readtextfromconsole, "%", 0)=1) And Not ($readtextfromconsole="")  Then
        $percentis = StringMid($readtextfromconsole, 1, 4)
        ProgressSet($progressbar2, Round($percentis))
MsgBox(0, $percentis, $readtextfromconsole);I check it with this and it never returns what I want
    EndIf
    Sleep(10)
WEnd

Can somebody help me with this? Here is a screen shot of console window:

post-27443-1219309562_thumb.jpg

Thanks in advance for any help.

Cheers ;)

Link to comment
Share on other sites

Hi,

I'm trying to read percentage from console window of makecab for updating my progress bar, but I'm having problems with it. I'm using following code but it wont work. I can get text return from console but I can't extract percentage numbers.

#include <Constants.au3>
$progressbar2 = ProgressOn("Test", "Please wait")
$runcheck=Run(""""&@SystemDir&"\makecab.exe"&""""&" /f ""D:\offxp\OFFICE1.ddf""", "D:\offxp", "", $STDOUT_CHILD)
While ProcessExists($runcheck)
        $readtextfromconsole = StdoutRead($runcheck)
        If (StringRegExp($readtextfromconsole, "%", 0)=1) And Not ($readtextfromconsole="")  Then
        $percentis = StringMid($readtextfromconsole, 1, 4)
        ProgressSet($progressbar2, Round($percentis))
MsgBox(0, $percentis, $readtextfromconsole);I check it with this and it never returns what I want
    EndIf
    Sleep(10)
WEnd

Can somebody help me with this? Here is a screen shot of console window:

post-27443-1219309562_thumb.jpg

Thanks in advance for any help.

Cheers :D

StringMid() returns at string, not surprisingly. Convert it to a number before using it:
$percentis = Number(StringMid($readtextfromconsole, 1, 4))

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...