Help with Progress bar Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Tomer
Posts: 196
Joined: 21 Aug 2016, 05:11

Help with Progress bar

13 Aug 2017, 02:20

hii
i guess this may be very simple for you to solve:

i would like have the progrss bar to be completed (100%) once the reading of list file is finished,
problem is the progress bar is completed to 100% before the read-list is finished.


Code: [Select all] [Download] GeSHi © Codebox Plus

Loop, read, c:\file.txt
{
Progress, %a_index%, %A_LoopReadLine%, Installing..., Draft Installation
Sleep, 50
}


thanks for any help..
Helgef
Posts: 2246
Joined: 17 Jul 2016, 01:02
Contact:

Re: Help with Progress bar  Topic is solved

13 Aug 2017, 03:52

Hello.
You need to set the progress in relation to the number of lines of the file. If you have 100 lines in file.txt, your code will end at 100 % progress. I'd do something like this,

Code: [Select all] [Download] GeSHi © Codebox Plus

fileRead, fileContent, file.txt
strReplace(fileContent,"`n","`n",lineCount) ; Count the number of lines

Loop, Parse, fileContent, `n, `r
{
Progress, % p:= round(100 * (A_Index-1) / lineCount,2), %A_LoopField% `n %p% `%, Installing..., Draft Installation
Sleep, 250
}

Cheers
User avatar
Tomer
Posts: 196
Joined: 21 Aug 2016, 05:11

Re: Help with Progress bar

13 Aug 2017, 04:14

Thanks Helgef,
thats working great.
i also liked the percentage show.

i came up with this code too,
which works for me good as well but its looks more complicated,
what your prefers\thoughts ?

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Helgef
Posts: 2246
Joined: 17 Jul 2016, 01:02
Contact:

Re: Help with Progress bar

13 Aug 2017, 05:14

Hello.
Short answer: if it is working for you, great :thumbup:
Slightly less short answer: It is a little wasteful to count the lines twice, that is, both Lines and count, holds the number of lines. Since you read the file with FileRead, Text, %1%, you might aswell use loop, parse instead of loop, read, to avoid reading the file again. I do not see where you use files:=(files ? "`n" : "") . A_LoopFileFullPath. Maybe that is part of a bigger script.

Cheers.
garry
Posts: 942
Joined: 22 Dec 2013, 12:50

Re: Help with Progress bar

13 Aug 2017, 06:54

thank you for the examples , here an example with GUI

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
Tomer
Posts: 196
Joined: 21 Aug 2016, 05:11

Re: Help with Progress bar

13 Aug 2017, 11:56

Very impressive garry! Will check it out at work tomorrow.
Thanks!!
Helgef
Posts: 2246
Joined: 17 Jul 2016, 01:02
Contact:

Re: Help with Progress bar

13 Aug 2017, 12:07

Nice indeed garry. :wave:
User avatar
Tomer
Posts: 196
Joined: 21 Aug 2016, 05:11

Re: Help with Progress bar

20 Aug 2017, 06:32

garry ive tryed to use your sample for my project,
when i use it to read only 1 file its works great (although i had to change total := (A_Index-1) tototal := (A_Index) only when the reading file doesnt have blank line at the end),
anyway i have a problem to use it while reading 2 or more separately files,
the "percents" goes over 100% and the list goes over its total round.

i tryed "reset" the gui controls so it may start a new counting but i failed to make it work..
i have added an smaple code so you can look out help me solving this issue.
tnx!

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

garry
Posts: 942
Joined: 22 Dec 2013, 12:50

Re: Help with Progress bar

20 Aug 2017, 07:17

shoul'd clear variables or set to zero
example reads first file (0-100%) than changes color from progressbar and reads second file ( 0-100% )

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
Tomer
Posts: 196
Joined: 21 Aug 2016, 05:11

Re: Help with Progress bar

20 Aug 2017, 07:24

so simple,
tnx garry

Return to “Ask For Help”

Who is online

Users browsing this forum: Bad husband, Bing [Bot], kczx3, ViewtifulDom, Yahoo [Bot] and 71 guests