AlMax3000 Posted November 30, 2019 Share Posted November 30, 2019 I try to add a progress bar.. ==> failing! 😔 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <SendMessage.au3> #include <Constants.au3> #Region ### START Koda GUI section ### Form= $FormName = "7-Zip Compressore" $Form1 = GUICreate($FormName, 550, 275, -1, -1) $Inp = GUICtrlCreateInput("", 8, 8, 465, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY)) $Out = GUICtrlCreateInput("", 8, 40, 465, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY)) $Pass = GUICtrlCreateInput("", 40, 72, 433, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE)) $BtnBrowse = GUICtrlCreateButton("B", 480, 6, 25, 25, $BS_ICON) $BtnBrowseFile = GUICtrlCreateButton("F", 515, 6, 25, 25, $BS_ICON) $BtnSave = GUICtrlCreateButton("S", 480, 38, 25, 25, $BS_ICON) $BtnCompress = GUICtrlCreateButton("OK", 480, 70, 25, 25, $BS_ICON) $BtnCancPass = GUICtrlCreateButton("X", 8, 70, 25, 25, $BS_ICON) $Group1 = GUICtrlCreateGroup("Sets level of compression", 8, 120, 257, 145) $Slider = GUICtrlCreateSlider(20, 146, 230, 25) GUICtrlSetLimit(-1, 5) GUICtrlSetData($Slider, '0') $CompLabel = GUICtrlCreateLabel("Ultra", 31, 182, 116, 15) $LabelSize = GUICtrlCreateLabel("", 31, 226, 200, 29) $progressbar = GUICtrlCreateProgress(8, 100, 465, 14) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $sFileName = @ScriptDir &"\pass.txt" $hFilehandle = FileOpen($sFileName, $FO_OVERWRITE) Local $7zDir = '"' & @ScriptDir & '\Bin\7z.exe"' Local $sFileVersion = FileGetVersion (@ScriptDir & "\Bin\7z.exe",$FV_FILEVERSION) Local $progressbar,$cmd $SliderCorrente = 5 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BtnBrowse $sSelectFolder = FileSelectFolder("Select Folder", "") If @error Then continueloop GUICtrlSetData($Inp, $sSelectFolder) $iSize = DirGetSize($sSelectFolder) GUICtrlSetData($LabelSize,"Dim: " & _GetDisplaySize($iSize)) Case $BtnBrowseFile $sFileOpenDialog = FileOpenDialog("Select files", @DesktopDir , "All (*.*)", $FD_FILEMUSTEXIST) If @error Then continueloop GUICtrlSetData($Inp, $sFileOpenDialog) $iSize = FileGetSize($sFileOpenDialog) GUICtrlSetData($LabelSize,"Dimensione: " & _GetDisplaySize($iSize)) Case $BtnSave $sFileSaveDialog = FileSaveDialog("Save files with name ", @DesktopDir , "Files type (*.7z)|Files type (*.zip)", $FD_PATHMUSTEXIST) GUICtrlSetData($Out, $sFileSaveDialog) If @error Then continueloop Case $BtnCompress GUICtrlSetData($progressbar,$cmd) If GUICtrlRead($Inp) = "" Then MsgBox(48, $FormName, "The boxes must not be empty!") ContinueLoop EndIf If GUICtrlRead($Out) = "" Then MsgBox(48, $FormName, "The boxes must not be empty!") ContinueLoop EndIf _Seven_Zip() Case $BtnCancPass GUICtrlSetData($pass,"") EndSwitch If GUICtrlRead($Slider) <> $SliderCorrente Then $SliderCorrente = GUICtrlRead($Slider) Select Case $SliderCorrente = 5 GUICtrlSetData($CompLabel, "Ultra") $livello = 9 Case $SliderCorrente = 4 GUICtrlSetData($CompLabel, "Maximum") $livello = 7 Case $SliderCorrente = 3 GUICtrlSetData($CompLabel, "Normal") $livello = 5 Case $SliderCorrente = 2 GUICtrlSetData($CompLabel, "Fast") $livello = 3 Case $SliderCorrente = 1 GUICtrlSetData($CompLabel, "Fastest") $livello = 1 Case $SliderCorrente = 0 GUICtrlSetData($CompLabel, "Copy") $livello = 0 EndSelect EndIf WEnd Func _GetDisplaySize($iSize, $iPlaces = 2) Local $aBytes[5] = [' Bytes', ' KB', ' MB', ' GB', ' TB'] For $i = 4 To 1 Step -1 If $iSize >= 1024 ^ $i Then Return Round($iSize / 1024 ^ $i, $iPlaces) & $aBytes[$i] EndIf Next Return $iSize & ' Bytes' EndFunc Func _Seven_Zip() If GUICtrlRead($pass) = "" Then $cmd = Run($7zDir & ' a -mx "' & GUICtrlRead($Out) & '" "' & GUICtrlRead($Inp) & '"',"",@SW_HIDE,$STDERR_MERGED) else $cmd = Run($7zDir & ' a -mx "' & GUICtrlRead($Out) & '" "' & '"-p"' & GUICtrlRead($pass) & '" "' & GUICtrlRead($Inp) & '\*"',"",@SW_HIDE,$STDERR_MERGED) GUICtrlSetData($progressbar,100) ProcessWaitClose ($cmd) Return StdoutRead($cmd) endif EndFunc Link to comment Share on other sites More sharing options...
Nine Posted November 30, 2019 Share Posted November 30, 2019 Ofc it doesn't work. You set GUICtrlSetData($progressbar,$cmd) where $cmp is a PID ! “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
AlMax3000 Posted November 30, 2019 Author Share Posted November 30, 2019 2 hours ago, Nine said: Ofc it doesn't work. You set GUICtrlSetData($progressbar,$cmd) where $cmp is a PID ! I try to link progress to _GetDisplaySize I think it will take many days 🙄 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now