Jump to content

Recommended Posts

Posted

Here is another one that should make the progress bar a bit smoother. It increments by 2 instead of 10. Again this is going by your image which shows each "." as being 2%. We replace ##% with a "." and then do a StringReplace to find out how "."s are in the string

Func progress() ;<--
    Local $Browse = GUICtrlRead($Input1) ;<--

    If $Browse <> '' Then ;<--If no file path in $Input1 the if loop ends
        Local $sSTO, $sPercent
        Local $comexe = Run("commandlineprogram.exe", @ScriptDir, @SW_HIDE, 2) ;<--

        While 1
            $sSTO = StdoutRead($comexe)
            If @error Then ExitLoop
        $sSTO = StringRegExpReplace($sSTO, "(\d{2,3}%)", "\.")
        StringReplace($sSTO, ".", "")
        $iPercent = @Extended
        If $iPercent Then
        $iPercent = $iPercent *2
        If GUICtrlRead($Progress1) <> $iPercent Then GUICtrlSetData($Progress1, $iPercent)
        EndIf
        WEnd

        Sleep(500)
        MsgBox(0, "Debug", "Done.")
        ; Finished
    EndIf
EndFunc ;==>progress

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted

I just downloaded that file but I have to go out for about an hour, I'll test it when I return.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted (edited)

What's wrong with this code?

It works for me in the way that you describe.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>

Global $totalTicks, $nMsg = ''

#region ### START Koda GUI section ### Form=
Global $Form2 = GUICreate("Form2", 413, 298, 192, 131)
Global $Progress1 = GUICtrlCreateProgress(128, 184, 150, 17)
Global $Input1 = GUICtrlCreateInput("Input1", 112, 24, 137, 21)
Global $Button1 = GUICtrlCreateButton("Button1", 168, 248, 75, 25, $WS_GROUP)
GUISetState()
#endregion ### END Koda GUI section ###

Do
    $nMsg = GUIGetMsg()

    Switch $nMsg
        Case $Button1
            progress()
    EndSwitch

    Sleep(20)
Until $nMsg = $GUI_EVENT_CLOSE

Exit

Func progress() ;<--
    Local $Browse = GUICtrlRead($Input1) ;<--

    If $Browse <> '' Then ;<--If no file path in $Input1 the if loop ends
        Local $maxTicks = 11 ;<-- Set the max number of % to expect from 0% - 100% = 11
        Local $comexe = Run("commandlineprogram.exe", @ScriptDir, @SW_HIDE, 2) ;<--
        Local $readTicks, $tickPercent

        While 1
            $readTicks = StdoutRead($comexe)

            If @error Then ExitLoop

            If $readTicks <> '' Then
                StringReplace($readTicks, "%", "0")
                $totalTicks += @extended
            EndIf

            $tickPercent = (($totalTicks / $maxTicks) * 100)
            GUICtrlSetData($Progress1, $tickPercent)
        WEnd

        Sleep(500)

        GUICtrlSetData($Progress1, 0)

        MsgBox(0, "Debug", "Done.")
        ; Finished
    EndIf
EndFunc ;==>progress
Edited by jaberwocky6669
Posted

What's wrong with this code?

It works for me in the way that you describe.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>

Global $totalTicks, $nMsg = ''

#region ### START Koda GUI section ### Form=
Global $Form2 = GUICreate("Form2", 413, 298, 192, 131)
Global $Progress1 = GUICtrlCreateProgress(128, 184, 150, 17)
Global $Input1 = GUICtrlCreateInput("Input1", 112, 24, 137, 21)
Global $Button1 = GUICtrlCreateButton("Button1", 168, 248, 75, 25, $WS_GROUP)
GUISetState()
#endregion ### END Koda GUI section ###

Do
    $nMsg = GUIGetMsg()

    Switch $nMsg
        Case $Button1
            progress()
    EndSwitch

    Sleep(20)
Until $nMsg = $GUI_EVENT_CLOSE

Exit

Func progress() ;<--
    Local $Browse = GUICtrlRead($Input1) ;<--

    If $Browse <> '' Then ;<--If no file path in $Input1 the if loop ends
        Local $maxTicks = 11 ;<-- Set the max number of % to expect from 0% - 100% = 11
        Local $comexe = Run("commandlineprogram.exe", @ScriptDir, @SW_HIDE, 2) ;<--
        Local $readTicks, $tickPercent

        While 1
            $readTicks = StdoutRead($comexe)

            If @error Then ExitLoop

            If $readTicks <> '' Then
                StringReplace($readTicks, "%", "0")
                $totalTicks += @extended
            EndIf

            $tickPercent = (($totalTicks / $maxTicks) * 100)
            GUICtrlSetData($Progress1, $tickPercent)
        WEnd

        Sleep(500)

        GUICtrlSetData($Progress1, 0)

        MsgBox(0, "Debug", "Done.")
        ; Finished
    EndIf
EndFunc ;==>progress

He said it worked for him too. I'm just showing him there are several ways of dealing with it, depending on how many steps he wants to increment the progress bar. Doing it with "%" it's going to jump 10% at a time. Each of those dots on the other hand represent 2% so it should be smoother.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted

thanks for all the help on this so far but i give up for now my head hurts. here is a screen of the app i'm making. this one is released already.

For the most part it works. i just wanted to hide the dos window that comes up, add a progress bar and make it tell what version of the app is installed. this is my 6th day at autoit and i'm tired. :mellow:

Posted Image

Posted

Here's another hint for you. If the file you linked to is the one you are actually trying to run, I'm not surprised that the code didn't work. Here is the retuurn running it from a command prompt

C:\Users\George\Desktop>commandlineprogram.exe

%ijojf5%JoIJ%OiJ%OIJ%OI%JojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%J%oIJ%OiJ%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y%9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoIJ%OiJ%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoIJ%OiJ%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoIJ%OiJ%OIJ%OI%%%JojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%

%ijojf5%JoIJ%%OiJ%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoIJ%OiJ%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoIJ%Oi%J%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoIJ%Oi%J%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoIJ%Oi%J%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoIJ%Oi%J%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoIJ%OiJ%O%IJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoIJ%OiJ%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoIJ%OiJ%OIJ%OIJ%ojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoIJ%OiJ%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoIJ%OiJ%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoI%J%Oi%J%O%IJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%

%ijojf5%JoIJ%OiJ%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijojf5%JoIJ%OiJ%OIJ%OIJ%ojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijoj%f5%JoIJ%OiJ%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijoj%f5%JoIJ%OiJ%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijoj%f5%JoIJ%OiJ%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

%ijoj%f5%JoIJ%OiJ%OIJ%OIJojnOIUHY&5*(&yH%%%%(*y9%HI%%%%%%%%%%%%%%%%

Although that might be because I don't have VirtualBox installed and I'm not about to install it either.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted

lol this is an exe that one of the guys here did to simulate the dos window screen i posted above. it was done to help test my script.

Posted (edited)

That accounts for why I didn't get the values we were looking for.

Test the one for steppping 2% and let me know what you get.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted

do you know how to write to a cmd window using autoit? then i'd be able to make a app to simulate my dos window for you.

$i = 0
While $i <= 100
    ConsoleWrite($i & "%, ")  ; <---->  instead of writing this to a console write it to the command window  -->  Run(@SystemDir & "\cmd.exe " & $i & "%, ")
    Sleep(1000)
    $i = $i + 10
WEnd
Posted (edited)

That accounts for why I didn't get the values we were looking for.

Test the one for steppping 2% and let me know what you get.

tried it but the progress bar don't show any activity

Edited by Tiboi
Posted

He said it worked for him too. I'm just showing him there are several ways of dealing with it, depending on how many steps he wants to increment the progress bar. Doing it with "%" it's going to jump 10% at a time. Each of those dots on the other hand represent 2% so it should be smoother.

Sorry, I must have missed that. Yes, the weird output is from a c/c++ exe that I made to test if if my changes were going to work for him. I intended him to replace my commandlineprogram.exe with his original commandlineprogram.exe because it should have just dropped in and worked.

Posted

do you know how to write to a cmd window using autoit? then i'd be able to make a app to simulate my dos window for you.

$i = 0
While $i <= 100
    ConsoleWrite($i & "%, ") ; <----> instead of writing this to a console write it to the command window --> Run(@SystemDir & "\cmd.exe " & $i & "%, ")
    Sleep(1000)
    $i = $i + 10
WEnd

Just compile that script with a program called Aut2Exe and be sure to select 'console app' (or whatever it is exactly). Aut2Exe should be in a folder called Aut2Exe in your AutoIt3 installation folder.
Posted (edited)

"GEOSoft" your code have a problem it goes up and down or back and forth, dont know what to call it.

I got my original code to work so here are they and a program i made to simulate the command line app that i am writing my program for. download the exe and use it to accurately test your code and see if you can get it to work,

cause i like your smoother concept than mine.

your code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 413, 298, 290, 179)
$Button1 = GUICtrlCreateButton("Button1", 176, 200, 75, 25)
$ProgressBar = GUICtrlCreateProgress(16, 96, 366, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
Case $Button1
Progress()
    EndSwitch
WEnd

Func Progress() ;<--
    Local $sSTO, $sPercent
    Local $Run = Run("commandlineapp.exe", @ScriptDir, @SW_HIDE, 2) ;<--

    While 1
        $sSTO = StdoutRead($Run)
        If @error Then ExitLoop
        $sSTO = StringRegExpReplace($sSTO, "(\d{2,3}%)", "\.")
        StringReplace($sSTO, ".", "")
        $iPercent = @extended
        If $iPercent Then
            $iPercent = $iPercent * 2
            If GUICtrlRead($ProgressBar) <> $iPercent Then GUICtrlSetData($ProgressBar, $iPercent)
        EndIf
    WEnd

    Sleep(500)
    MsgBox(0, "Debug", "Done.")
    ; Finished
EndFunc   ;==>Progress

this is my moded version that works

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 413, 298, 290, 179)
$Button1 = GUICtrlCreateButton("Button1", 176, 200, 75, 25)
$ProgressBar = GUICtrlCreateProgress(16, 96, 366, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
Case $Button1
Progress()
    EndSwitch
WEnd

Func Progress()
    Local $totalTicks
    Local $maxTicks = 11 ;<-- Set the max number of % to expect
Local $Run = Run("commandlineapp.exe", @ScriptDir, @SW_HIDE, 2) ;<--
    While ProcessExists($Run)
        $readTicks = StdoutRead($Run) ;<--Read from the child's STDOUT
        If Not @error And $readTicks <> '' Then ; <--if StdoutRead sets @error to -1 we're at EOF, so exit
            StringReplace($readTicks, "%", "0") ; <--StringReplace keeps a count of chars it replaces in @extended
            $totalTicks += @extended
            $tickPercent = (($totalTicks / $maxTicks) * 100) ; <--Adjust the progress bar
            GUICtrlSetData($ProgressBar, $tickPercent)
        EndIf
    WEnd
    Sleep(500)
    MsgBox(0, "Debug", "Done.")
    GUICtrlSetData($ProgressBar, 0)
EndFunc   ;==>Progress

and the commandlineapp.exe simulator i made to test the code. its useful:)

http://www.mediafire.com/?zjkweyqm5mx
Edited by Tiboi
Posted (edited)

Yes, your moded version works well

and for compile your script for console app more faster :

If Not @Compiled Then _CompileForConsole ( )

For $_I = 0 To 100 Step 10
    ConsoleWrite ( $_I & "%, " ) 
    Sleep ( 1000 )
Next

Func _CompileForConsole ( $_Icon=@ProgramFilesDir & '\AutoIt3\Icons\au3script_v10.ico' )
    RunWait ( @ProgramFilesDir & '\AutoIt3\Aut2Exe\Aut2exe.exe /in "' & @ScriptFullPath & '" /icon "' & $Icon & '" /comp 4 /console' )
    Exit
EndFunc ;==> _CompileForConsole ( )
Edited by wakillon

AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts

Posted

Yes, your moded version works well

and for compile your script for console app more faster :

If Not @Compiled Then _CompileForConsole ( )

For $_I = 0 To 100 Step 10
    ConsoleWrite ( $_I & "%, " ) 
    Sleep ( 1000 )
Next

Func _CompileForConsole ( $_Icon=@ProgramFilesDir & '\AutoIt3\Icons\au3script_v10.ico' )
    RunWait ( @ProgramFilesDir & '\AutoIt3\Aut2Exe\Aut2exe.exe /in "' & @ScriptFullPath & '" /icon "' & $Icon & '" /comp 4 /console' )
    Exit
EndFunc ;==> _CompileForConsole ( )

i don't understand what you mean, could you please explain more clearly? thanks

Posted

Without checking your code yet (I will as soon as I can), the problem there, I suspect, will be becuase there is some movement there while it's running.

Change

If GUICtrlRead($ProgressBar) <> $iPercent Then GUICtrlSetData($ProgressBar, $iPercent)
to
If GUICtrlRead($ProgressBar) < $iPercent Then GUICtrlSetData($ProgressBar, $iPercent)

That should force it to only run in one direction.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted (edited)

Tiboi

i don't understand what you mean, could you please explain more clearly? thanks

Sorry...

To avoid compile in console mode with Aut2Exe gui

just start the script and it compile in console mode itself !

It's faster!

Edited by wakillon

AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts

Posted

Tiboi

i don't understand what you mean, could you please explain more clearly? thanks

Sorry...

To avoid compile in console mode with Aut2Exe gui

just start the script and it compile in console mode itself !

It's faster!

i hear what you are saying but i still don't understand because i don't compile my scripts in console mode

Posted

Without checking your code yet (I will as soon as I can), the problem there, I suspect, will be becuase there is some movement there while it's running.

Change

If GUICtrlRead($ProgressBar) <> $iPercent Then GUICtrlSetData($ProgressBar, $iPercent)
to
If GUICtrlRead($ProgressBar) < $iPercent Then GUICtrlSetData($ProgressBar, $iPercent)

That should force it to only run in one direction.

it starts and sticks then shows done

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
×
×
  • Create New...