DarkBoost Posted May 26, 2016 Posted May 26, 2016 Hi, I have created an AutoIT script which includes about 1500 Resource Files and I'm using the FileInstall to extract them. I have this all compiling and extracting correctly and now wanting to check the progress of each file as it Extracts and link this to the GUI Progress which is where I'm unsure. I was thinking of simply continuing to check the output folder size to see how many files are there but if I run this in a loop it won't continue with the FileInstall? I was also thinking of using GUIRegisterMsg but not what Windows Message I could use to trigger the function as it's doing the FileInstall? Any ideas would be great, thanks!
AutoBert Posted May 26, 2016 Posted May 26, 2016 You can update your progress after each FileInstall.
orbs Posted May 26, 2016 Posted May 26, 2016 2 hours ago, DarkBoost said: ... about 1500 Resource Files ... and you have 1500 FileInstall calls in your script ?! how about this: compress them all to a 7z archive, and when extracting you can read the stdout of 7z.exe and parse the percentage indicator. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
DarkBoost Posted May 26, 2016 Author Posted May 26, 2016 Yes there are many of ways of doing this however AutoIT has this feature and I would like to use it. Here is a small example of my script - I and not sure how to get the Progress to Update after each file has been installed. I do not want to hard code a Progress Update after each FileInstall if possible. Thanks. expandcollapse popup#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_File_Add=D:\script\File_001.txt #AutoIt3Wrapper_Res_File_Add=D:\script\File_002.txt #AutoIt3Wrapper_Res_File_Add=D:\script\File_003.txt #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> GUICreate("Title", 300, 120) Global $PROGRESS = GUICtrlCreateProgress(10, 10, 280, 30) Global $BUTTON = GUICtrlCreateButton("Install", 10, 50, 280, 60) GUISetState(@SW_SHOW) Global $MSG While 1 $MSG = GUIGetMsg() Select Case $MSG = $GUI_EVENT_CLOSE GUIDelete() Exit Case $MSG = $BUTTON _install() EndSelect WEnd Func _install() Local $INSTALL = "D:\Install" DirCreate($INSTALL) FileInstall("D:\script\File_001.txt", $INSTALL & "\File_001.txt") FileInstall("D:\script\File_002.txt", $INSTALL & "\File_002.txt") FileInstall("D:\script\File_003.txt", $INSTALL & "\File_003.txt") MsgBox(0, "Finished", "Files have been installed...") EndFunc
orbs Posted May 26, 2016 Posted May 26, 2016 write a wrapper function for FileInstall, which accepts the same parameters as FileInstall, performs the FileInstall exactly the same way, but in addition increases the progress bar by some percent. then replace all your FileInstall calls with that function. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
DarkBoost Posted May 26, 2016 Author Posted May 26, 2016 I am not sure what a wrapper function is, could you please elaborate?
orbs Posted May 26, 2016 Posted May 26, 2016 Func FileInstallWithProgress($sSource, $sDest, $iFlag = 0) FileInstall($sSource, $sDest, $iFlag) GUICtrlSetData($PROGRESS, GUICtrlRead($PROGRESS) + 1) ; assuming you increase progress by 1% EndFunc ;==>FileInstallWithProgress this function "wraps" the FileInstall call, hence "wrapper". call this function in your main script instead of calling FileInstall. Skysnake 1 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
AutoBert Posted May 26, 2016 Posted May 26, 2016 or like this: Func _FileInstallWithProgress($source, $dest, $flag = 0, $id = 0, $progress = 0) FileInstall($source, $dest, $flag) If $id <> 0 Then GUICtrlSetData($id, GUICtrlRead($id) + $progress) EndFunc
BrewManNH Posted May 26, 2016 Posted May 26, 2016 You can't use FileInstall with a variable as the source parameter. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
AutoBert Posted May 26, 2016 Posted May 26, 2016 Ups, shame on me. Once a time posting without testing and result like a noob.
DarkBoost Posted May 26, 2016 Author Posted May 26, 2016 (edited) 11 hours ago, BrewManNH said: You can't use FileInstall with a variable as the source parameter. Yeah this is why I posted here... I have just found a solution as shown below, thanks! #include <Array.au3> Global $array[1] = [0] Global $path = "d:\install\" _ArrayAdd($array, FileInstall("d:\file_001.txt", $path & "file_001.txt")) _ArrayAdd($array, FileInstall("d:\file_002.txt", $path & "file_002.txt")) _ArrayAdd($array, FileInstall("d:\file_003.txt", $path & "file_003.txt")) DirCreate($path) $array[0] = Ubound($array) - 1 For $a = 1 To $array[0] Execute($array[$a]) Next Edited May 27, 2016 by DarkBoost
DarkBoost Posted May 27, 2016 Author Posted May 27, 2016 (edited) Nope this isn't working as expected, it's doing the FileInstall as it's being added to the Array Bit the bullet and hardcoded the progress which wasn't too bad since the code was being generated anyways. Edited May 27, 2016 by DarkBoost
AutoBert Posted May 27, 2016 Posted May 27, 2016 (edited) Make it like this: expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <Array.au3> Global $array[1] = [0] Global $path = "c:\install\" _ArrayAdd($array, 'FileInstall("test.au3", $path & "file_001.txt")') _ArrayAdd($array, 'FileInstall("test2.au3", $path & "file_002.txt")') _ArrayAdd($array, 'FileInstall("test3.au3", $path & "file_003.txt")') DirCreate($path) $array[0] = UBound($array) - 1 ;_ArrayDisplay($array) $hGui = GUICreate("Fileinstall Test", 300, 125, 302, 218) $idprgInfo = GUICtrlCreateProgress(8, 70, 285, 30) $hGUI_c = GUICreate("", 184, 30, 8, 73, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TRANSPARENT, $WS_EX_MDICHILD), $hGui) GUISetBkColor(0x989898, $hGUI_c) $idlblInfo = GUICtrlCreateLabel("0", 0, 0, 184, 25, $ES_CENTER) GUICtrlSetFont(-1, 12, 1000) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) _WinAPI_SetLayeredWindowAttributes($hGUI_c, 0x989898) GUISetState(@SW_SHOW, $hGui) GUISetState(@SW_SHOWNA, $hGUI_c) For $a = 1 To $array[0] Sleep(Random(500,2000,1)) Execute($array[$a]) _ShowProgress($a*100/$array[0],$idprgInfo,$idlblInfo) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _ShowProgress($iPercent,$idPrg,$idLbl=0) ConsoleWrite($iPercent&@CRLF) Local Static $iOld if int($iPercent)=$iOld Then Return Else $iOld=Int($iPercent) EndIf GUICtrlSetData($idPrg,$iPercent) if $idLbl<>0 Then GUICtrlSetData($idLbl,$iPercent) EndFunc this works for me, the sleep is only that you can see the progress after each FileInstall, you can remove it or use a small fix sleeptime. Edit: works only as script not as compiled exe. Edited May 27, 2016 by AutoBert
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