Jump to content

How do I calculate the exact percentage on Progress


Recommended Posts

I was a new person. Can anybody give me an example of percentage from Func install using Fileinstall

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$GUI_M = GUICreate("Program setting", 544, 200)
$Install = GUICtrlCreateButton("Install", 280, 130, 100, 30)
GUICtrlSetFont(-1, 12,900)
$out = GUICtrlCreateButton("Exit", 100, 130, 100, 30)
GUICtrlSetFont(-1, 12,900)
$process = GUICtrlCreateProgress(16, 50, 465, 17)
$percent = GUICtrlCreateLabel("0 %", 496, 50, 36, 17)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Install
            _Install()
        Case $GUI_EVENT_CLOSE, $out
            Exit

    EndSwitch
WEnd

Func _Install()
DirCreate("C:\Salary Employment day")
DirCreate("C:\Salary Employment day\UserLogin")
FileInstall("AvtIntel 001.jpg", "Salary Employment day\UserLogin\AvtIntel 001.jpg",1)
FileInstall("AvtIntel 002.jpg", "Salary Employment day\UserLogin\AvtIntel 002.jpg",1)
FileInstall("AvtIntel 003.jpg", "Salary Employment day\UserLogin\AvtIntel 003.jpg",1)
FileInstall("AvtIntel 004.jpg", "Salary Employment day\UserLogin\AvtIntel 004.jpg",1)
FileInstall("AvtIntel 005.jpg", "Salary Employment day\UserLogin\AvtIntel 005.jpg",1)
FileInstall("AvtIntel 006.jpg", "Salary Employment day\UserLogin\AvtIntel 006.jpg",1)
FileInstall("AvtIntel 007.jpg", "Salary Employment day\UserLogin\AvtIntel 007.jpg",1)
FileInstall("AvtIntel 008.jpg", "Salary Employment day\UserLogin\AvtIntel 008.jpg",1)
FileInstall("AvtIntel 009.jpg", "Salary Employment day\UserLogin\AvtIntel 009.jpg",1)
FileInstall("AvtIntel 010.jpg", "Salary Employment day\UserLogin\AvtIntel 010.jpg",1)
FileInstall("AvtIntel 011.jpg", "Salary Employment day\UserLogin\AvtIntel 011.jpg",1)
FileInstall("AvtIntel 012.jpg", "Salary Employment day\UserLogin\AvtIntel 012.jpg",1)
EndFunc

 

Link to post
Share on other sites
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$GUI_M = GUICreate("Program setting", 544, 200)
$Install = GUICtrlCreateButton("Install", 280, 130, 100, 30)
GUICtrlSetFont(-1, 12,900)
$out = GUICtrlCreateButton("Exit", 100, 130, 100, 30)
GUICtrlSetFont(-1, 12,900)
$process = GUICtrlCreateProgress(16, 50, 465, 17)
$percent = GUICtrlCreateLabel("0 %", 496, 50, 36, 17)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Install
            _Install()
        Case $GUI_EVENT_CLOSE, $out
            Exit
    EndSwitch
WEnd

Func _Install()
    DirCreate("C:\Salary Employment day")
    DirCreate("C:\Salary Employment day\UserLogin")
    
    FileInstall("AvtIntel 001.jpg", "Salary Employment day\UserLogin\AvtIntel 001.jpg",1)
    Progress(1/12)
    FileInstall("AvtIntel 002.jpg", "Salary Employment day\UserLogin\AvtIntel 002.jpg",1)
    Progress(2/12)
    FileInstall("AvtIntel 003.jpg", "Salary Employment day\UserLogin\AvtIntel 003.jpg",1)
    Progress(3/12)
    FileInstall("AvtIntel 004.jpg", "Salary Employment day\UserLogin\AvtIntel 004.jpg",1)
    Progress(4/12)
    FileInstall("AvtIntel 005.jpg", "Salary Employment day\UserLogin\AvtIntel 005.jpg",1)
    Progress(5/12)
    FileInstall("AvtIntel 006.jpg", "Salary Employment day\UserLogin\AvtIntel 006.jpg",1)
    Progress(6/12)
    FileInstall("AvtIntel 007.jpg", "Salary Employment day\UserLogin\AvtIntel 007.jpg",1)
    Progress(7/12)
    FileInstall("AvtIntel 008.jpg", "Salary Employment day\UserLogin\AvtIntel 008.jpg",1)
    Progress(8/12)
    FileInstall("AvtIntel 009.jpg", "Salary Employment day\UserLogin\AvtIntel 009.jpg",1)
    Progress(9/12)
    FileInstall("AvtIntel 010.jpg", "Salary Employment day\UserLogin\AvtIntel 010.jpg",1)
    Progress(10/12)
    FileInstall("AvtIntel 011.jpg", "Salary Employment day\UserLogin\AvtIntel 011.jpg",1)
    Progress(11/12)
    FileInstall("AvtIntel 012.jpg", "Salary Employment day\UserLogin\AvtIntel 012.jpg",1)
    Progress(12/12)
EndFunc

Func Progress($value)
    $value *= 100
    GUICtrlSetData($process, $value)
    GUICtrlSetData($percent, Round($value,0) & " %")
EndFunc

 

Link to post
Share on other sites
  • 1 month later...

I am writing a download on my site but I can't calculate progress and percentage. help me please
Here is my code:

#include <ProgressConstants.au3>
#include <GUIConstantsEx.au3>
#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

$GUI = GUICreate("Download", 600, 250)
GUISetFont(12, 400, 0, "Arial Narrow")
$Progress = GUICtrlCreateProgress(64, 88, 457, 41)
$percent = GUICtrlCreateLabel("", 544, 104, 59, 24)
$Dow = GUICtrlCreateButton("Download", 192, 200, 105, 33)
$Exit = GUICtrlCreateButton("Exit", 352, 200, 107, 33)
$CmtProgress = GUICtrlCreateLabel("", 88, 160, 444, 24)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE,$Exit
            Exit
        Case $Dow
            _Download()

    EndSwitch
WEnd


Func _Download()
Local $url = "https://dl.dropboxusercontent.com/s/6ecq0hzxr7hssd9/Image.jpg"
Local $hDownload = InetGet($url ,@DesktopDir & "\Imagex.jpg", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
Local $size = InetGetSize($url)
Do

;Download progress and percentage

Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
InetClose($hDownload)
If GUICtrlRead($Progress) = 100 Then
GUICtrlSetData($CmtProgress, "Download successfully")
EndIf
EndFunc

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...