Sign in to follow this  
Followers 0
Ghost21

Progress Bar Scaleing

9 posts in this topic

I have a progress bar eg.

$Progressbar = GUICtrlCreateProgress(7, 72, 432, 12)

<-----------------------------------------------------------------------------------------> Say 100 points long

Now what is happening when I use the progress bar its filling the bar past what I can see for example it finds new records and goes to 177 but I can only see to 100. I would like it to load the 177 so it ends at the 100 point..

Hopefully that makes sense to someone muttley

I don't want to change the display SIZE of the bar.

Thanks

Share this post


Link to post
Share on other sites



I have a progress bar eg.

$Progressbar = GUICtrlCreateProgress(7, 72, 432, 12)

<-----------------------------------------------------------------------------------------> Say 100 points long

Now what is happening when I use the progress bar its filling the bar past what I can see for example it finds new records and goes to 177 but I can only see to 100. I would like it to load the 177 so it ends at the 100 point..

Hopefully that makes sense to someone muttley

I don't want to change the display SIZE of the bar.

Thanks

To find the percentage of each increment, just divide 100 (which is the total length of the progress bar) by the total (177 records). Then after each record is processed, add 100/177 to the current progress.

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt

Share this post


Link to post
Share on other sites

To find the percentage of each increment, just divide 100 (which is the total length of the progress bar) by the total (177 records). Then after each record is processed, add 100/177 to the current progress.

Falls over shaking... Umm This is what I have

$Progressbar = GUICtrlCreateProgress(7, 72, 432, 12)

For $iIndex = 1 To $oRS.RecordCount

GUICtrlSetData($Progressbar, $iIndex)

$oRS.MoveNext

Next

Where abouts to I include that calculation.. ?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Falls over shaking... Umm This is what I have

$Progressbar = GUICtrlCreateProgress(7, 72, 432, 12)

For $iIndex = 1 To $oRS.RecordCount

GUICtrlSetData($Progressbar, $iIndex)

$oRS.MoveNext

Next

Where abouts to I include that calculation.. ?

$Progressbar = GUICtrlCreateProgress(7, 72, 432, 12)
$progress = 0

For $iIndex = 1 To $oRS.RecordCount
GUICtrlSetData($Progressbar, $progress)
$progress += 100/$oRS.RecordCount
$oRS.MoveNext
Next
Edited by Airwolf

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt

Share this post


Link to post
Share on other sites

$Progressbar = GUICtrlCreateProgress(7, 72, 432, 12)
$progress = 0

For $iIndex = 1 To $oRS.RecordCount
GUICtrlSetData($Progressbar, $progress)
$progress += 100/177
$oRS.MoveNext
Next
Why is the $progress += 100/177 after it sets it ???

Share this post


Link to post
Share on other sites

Why is the $progress += 100/177 after it sets it ???

To add another 100/177 to the $progress variable so that the next time the For loop kicks off and the progress bar is updated, it will display the proper percentage. Without the $progress += 100/177 line, the progress bar would be updated to 0% every time.

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt

Share this post


Link to post
Share on other sites

To add another 100/177 to the $progress variable so that the next time the For loop kicks off and the progress bar is updated, it will display the proper percentage. Without the $progress += 100/177 line, the progress bar would be updated to 0% every time.

Ahhh.. Man that makes way more sense.. Thanks for the GREAT HELP...

P.S. IT worked perfect...

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Just for reference, here's what I did on mine.

Func _cList()
    WinActivate($title)
    
    Dim $aList[1][5]
    
    $i_path_1 = FileOpenDialog("Load Forms", @DesktopDir & "\", "MS Excel Files (*.xl*;*.xls)", 4)
    $i_path_2 = FileOpenDialog("Create List or Add to a List", @DesktopDir & "\", "MS Excel Files (*.xl*;*.xls)")
    
    $aFiles = StringSplit($i_path_1, '|')
    
    ;_ArrayDisplay ($aFiles, "$aFiles") ; for debug
    
    $mousePos = MouseGetPos()
    
    _MouseTrap($mousePos[0], $mousePos[1], $mousePos[0], $mousePos[1])
    
    $prog_gui = GuiCreate("Please wait", 500, 70, -1, $guiloc_y-100)
    $prog_bar1 = GUICtrlCreateProgress ($offset_1, 5, 475, 10, $PBS_SMOOTH)
    $prog_bar2 = GUICtrlCreateProgress ($offset_1, 20, 475, 10, $PBS_SMOOTH)
    $prog_label = GUICtrlCreateLabel ("", $offset_1, 35, 475, 25)
    GUISetState (@SW_SHOW, $prog_gui)
    $prog_perc1 = 0
    $prog_perc2 = 0
    
    For $ia = 0 To Ubound($aFiles) - 3
        $cOrig = 26 ;26 or 28
        
        GUICtrlSetData ($prog_label, "Reading..." & @CRLF & $aFiles[1] & "\" & $aFiles[$ia+2])
        $aList[$ia][0] = _ExcelReadCell($rExcel, "C5")              ; description
        $aList[$ia][1] = _ExcelReadCell($rExcel, "C7")              ; manufacturer
        $aList[$ia][2] = _ExcelReadCell($rExcel, "C9")              ; mfg partnumber
        $aList[$ia][3] = _ExcelReadCell($rExcel, "C" & $cOrig)      ; originator name
        $ord = _ExcelReadCell($rExcel, "P" & $cOrig)                ; originator date
        _ExcelBookClose($rExcel)
        
        $ord = StringLeft(String($ord), 8)
        $ordm = StringRight(StringLeft($ord, 6), 2)
        $ordd = StringRight($ord, 2)
        $ordy = StringLeft($ord, 4)
        $aList[$ia][4] = $ordm & "/" & $ordd & "/" & $ordy
        
        ReDim $aList[UBound($aList) + 1][Ubound($aList, 2)]
        $prog_perc1 += 100 / (Ubound($aFiles) - 3)
        GUICtrlSetData ($prog_bar1, $prog_perc1)
    Next
    
    For $ib = 0 To UBound($aList) - 1
        $cl = 2
        GUICtrlSetData ($prog_label, "Writing..." & @CRLF & $i_path_2)
        Local $oExcel = _ExcelBookOpen($i_path_2, 0)
        
        While _ExcelReadCell($oExcel, "B" & $cl) <> ""
            $cl = $cl+1
        WEnd
        
        _ExcelWriteCell($oExcel, $aList[$ib][0], "B" & $cl)     ; description
        _ExcelWriteCell($oExcel, $aList[$ib][1], "C" & $cl)     ; manufacturer
        _ExcelWriteCell($oExcel, $aList[$ib][2], "D" & $cl)     ; mfg partnumber
        _ExcelWriteCell($oExcel, $aList[$ib][3], "J" & $cl)     ; originator name
        _ExcelWriteCell($oExcel, $aList[$ib][4], "K" & $cl)     ; originator date
        
        _ExcelBookClose($oExcel)
        $prog_perc2 += 100 / Ubound($aList)
        GUICtrlSetData ($prog_bar2, $prog_perc2)
    Next
    
    _MouseTrap()
    
    MsgBox(0, "Done.", "Task is complete.")
    GUISetState (@SW_HIDE, $prog_gui)
EndFunc
Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites

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