Jump to content

Recommended Posts

Posted (edited)

Do you like the simplicity of ProgressOn, ProgressSet and ProgressOff but want them in a gui? Now you can.

I made this UDF to replicate the pop up progress bar. ProgressSet acts mostly the same. ProgressOn is different.

#include <GUIConstants.au3>
#include <file.au3>

GUICreate("Progress Demo", 600, 500)
GUISetState()
Dim $progress, $main, $sub
$prog = _ProgressOn($progress, $main, $sub, "This is the main text", "This is the sub-text", 150, 10)
For $i = 1 To 100
 _ProgressSet($prog, $i, "This is the sub-text " & $i & "%")
 Sleep(100)
Next
_ProgressOff($prog)
$prog = _ProgressOn($progress, $main, $sub, "This will change", "This is a moved example", 320, 300, 1)
Sleep(1000)
For $i = 1 To 100
 _ProgressSet($prog, $i, "", "This time the main text changes") ;use "" for the default string
 Sleep(100)
Next
_ProgressOff($prog)
While 1
 Switch GUIGetMsg()
  Case $GUI_EVENT_CLOSE
   Exit
 EndSwitch
WEnd
;=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
;UDF Below
;=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=


;===============================================================================
;
; Function Name:   _ProgressOn
; Description::    Creates a 'ProgressOn like' progress bar in a gui
; Syntax:     Dim $progress, $main, $sub ;make sure you dim the first three variables. they are the controlId's
;       _ProgressOn($progress, $main, $sub, "This is the main text", "This is the sub-text", 150, 10)
; Parameter(s):    $s_mainlabel($main-text var), $s_sublabel($sub-text var),
;       $s_control($progress var), $s_main(Main text), $s_sub(Sub Text), $x(Position), $y(Position), $fSmooth(1 for smooth, 0 for not smooth)
; Requirement(s):  AutoIt, #include <file.au3>
; Return Value(s): Success - Returns array
;       $array[0] - $progress id
;       $array[1] - Main Label
;       $array[2] - Sub label
;       $array[3] - x pos
;       $array[4] - y pos
;       Failure - 0 and sets @error to 1
; Author(s):       RazerM
;
;===============================================================================
;
Func _ProgressOn(ByRef $s_mainlabel, ByRef $s_sublabel, ByRef $s_control, $s_main, $s_sub, $x, $y, $fSmooth = 0)
 $s_mainlabel = GUICtrlCreateLabel($s_main, $x, $y, StringLen($s_main) * 10)
 If $s_mainlabel = 0 Then
  SetError(1)
  Return 0
 EndIf
 GUICtrlSetFont($s_mainlabel, 14)
 If StringInStr(@OSTYPE, "WIN32_NT") And $fSmooth = 1 Then
  $prev = DllCall("uxtheme.dll", "int", "GetThemeAppProperties");, "int", 0)
  DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
 EndIf
 $s_control = GUICtrlCreateProgress($x, $y + 30, 260, 20, $PBS_SMOOTH)
 If StringInStr(@OSTYPE, "WIN32_NT") And $fSmooth = 1 Then
  DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $prev[0])
 EndIf
 If $s_control = 0 Then
  SetError(1)
  Return 0
 EndIf
 $s_sublabel = GUICtrlCreateLabel($s_sub, $x, $y + 55)
 If $s_sublabel = 0 Then
  SetError(1)
  Return 0
 EndIf
 Dim $a_info[5]
 $a_info[0] = $s_control
 $a_info[1] = $s_mainlabel
 $a_info[2] = $s_sublabel
 $a_info[3] = $x
 $a_info[4] = $y
 Return $a_info
EndFunc   ;==>_ProgressOn
;===============================================================================
;
; Function Name:   _ProgressSet
; Description::    Sets a progressbar created with _ProgressOn
; Parameter(s):    $a_info(Progress Id returned by _ProgressOn), $i_per(Percent), $s_sub(Sub text)[optional], $s_main(main text)[optional]
; Requirement(s):  AutoIt, #include <file.au3>
; Return Value(s): Success - 1, Failure - 0 and sets @error to 1
; Author(s):       RazerM
;
;===============================================================================
;
Func _ProgressSet($a_info, $i_per, $s_sub = "", $s_main = "")
 If $s_main = "" Then $s_main = GUICtrlRead($a_info[1])
 If $s_sub = "" Then $s_sub = GUICtrlRead($a_info[2])
 $set1 = GUICtrlSetData($a_info[0], $i_per)
 $set2 = GUICtrlSetData($a_info[1], $s_main)
 $set3 = GUICtrlSetData($a_info[2], $s_sub)
 GUICtrlSetPos($a_info[2], $a_info[3], $a_info[4] + 55, StringLen($s_sub) * 6)
 GUICtrlSetPos($a_info[1], $a_info[3], $a_info[4], StringLen($s_main) * 10)
 If ($set1 = 0) Or ($set2 = 0) Or ($set3 = 0) Then
  SetError(1)
  Return 0
 EndIf
 If ($set1 = -1) Or ($set2 = -1) Or ($set3 = -1) Then
  SetError(1)
  Return 0
 EndIf
 Return 1
EndFunc   ;==>_ProgressSet

;===============================================================================
;
; Function Name:   _ProgressOff()
; Description::    Deletes a progress bar created with _ProgressOn()
; Parameter(s):    $a_info(Progress Id returned by _ProgressOn)
; Requirement(s):  AutoIt, #include <file.au3>
; Return Value(s): Success - 1, Failure - 0 and sets @error to 1
; Author(s):       RazerM
;
;===============================================================================
;

Func _ProgressOff($a_info)
 $del1 = GUICtrlDelete($a_info[1])
 $del2 = GUICtrlDelete($a_info[2])
 $del3 = GUICtrlDelete($a_info[0])
 If ($del1 = 0) Or ($del2 = 0) Or ($del3 = 0) Then
  SetError(1)
  Return 0
 EndIf
EndFunc   ;==>_ProgressOff

The UDF is on it's own here:Progress.au3

Previous Downloads: 191

Update: Added $fSmooth into _ProgressOn, set to 1 for a smooth prgress bar

Edited by RazerM
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Posted

no problem

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Posted

I have updated the udf to use an array

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Posted

I'm still a noob, so please excuse my ignorance.

Where might I be able to find the #includes?

What's the easiest way to get them?

Is there a part of the forum for noobs?

Thx

Posted

I'm still a noob, so please excuse my ignorance.

Where might I be able to find the #includes?

What's the easiest way to get them?

Is there a part of the forum for noobs?

Thx

"Welcome to Autoit 1-2-3" is your friend

click below ( in the signature area)

8)

NEWHeader1.png

  • 5 months later...
Posted

I've updated the UDF with a "smooth" paramater that sets the Progress Bar with a $PBS_SMOOTH style(Works on WinXP too)

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
  • 2 weeks later...
Posted

is there any way to have a break in the progress? I want to be able to have an OK button to stop a countdown. Also if possible, and is there any way to make the size of the _ProgressSet text box any bigger? My text is being cut off :lmao:

Posted

It should be the correct size automatically, post the script you are having trouble with please.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
  • 1 year later...
Posted

I'm still a noob, so please excuse my ignorance.

Where might I be able to find the #includes?

What's the easiest way to get them?

Is there a part of the forum for noobs?

Thx

You may read it's location at autoit.chm file, just look for it.....Hahhaha

Posted

You may read it's location at autoit.chm file, just look for it.....Hahhaha

You realizing that you are answering to a post that is actualy 2 years old? :D

P.S

Nice UDF @RazerM :D

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 2 years later...

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...