anothergeorge Posted August 12, 2018 Share Posted August 12, 2018 Hey people! I've searched the forums and looked through the help file, but can't figure out how to implement a method to increment my progress bar in a simple copy/paste app with GUI. I've made the GUI fully functional and the code behind the app is really simple. I focused only on pure functionality, but the progress bar is where I got stuck. Here is my snippet: Spoiler #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $form1 = GUICreate("File Handler", 427, 143, 744, 218) $buttonCopy = GUICtrlCreateButton("Copy", 16, 104, 75, 25) $buttonMove = GUICtrlCreateButton("Move", 128, 104, 75, 25) $buttonDelete = GUICtrlCreateButton("Delete", 240, 104, 75, 25) $buttonSelectFile = GUICtrlCreateButton("File", 336, 8, 75, 20) $buttonDestinationPath = GUICtrlCreateButton("Folder", 336, 40, 75, 20) $buttonExit = GUICtrlCreateButton("Exit", 336, 72, 75, 20) $pathFile = GUICtrlCreateInput("", 16, 8, 297, 21) $pathDestination = GUICtrlCreateInput("", 16, 40, 297, 21) $Progress1 = GUICtrlCreateProgress(16, 72, 297, 17, $WS_BORDER) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg ;Select File button Case $buttonSelectFile $filePath = FileOpenDialog("Select File", "C:\", "All (*.*)") GUICtrlSetData($pathFile, $filePath) ;Select Destination Button Case $buttonDestinationPath If @error Then $buttonDestinationPath = "" EndIf $destinationPath = FileSelectFolder("Select Destination", "C:\") GUICtrlSetData($pathDestination, $destinationPath) ;Button starts copy action Case $buttonCopy $copyAction = FileCopy($filePath, $destinationPath, $Progress1) If $copyAction = 1 Then MsgBox(0, "Copy file", "Success!") Else MsgBox(0, "Copy file", "Fail!") EndIf ;Button starts move action Case $buttonMove $moveAction = FileMove($filePath, $destinationPath) If $moveAction = 1 Then MsgBox(0, "Move file", "Success!") Else MsgBox(0, "Move file", "Fail!") EndIf ;Button starts delete action Case $buttonDelete $deleteAction = FileDelete($filePath) If $deleteAction = 1 Then MsgBox(0, "Delete file", "Success!") Else MsgBox(0, "Delete file", "Fail!") EndIf ;Exit Case $buttonExit Exit EndSwitch WEnd I need the progress bar only for copy/move. Any advices, please? Link to comment Share on other sites More sharing options...
careca Posted August 12, 2018 Share Posted August 12, 2018 (edited) honestly i dont see why you would need a progress bar in a single file copy. usually when i copy lots of files and i want a progress bar, i use a for loop with the total count of files and go from there, if you know what i mean, but for a single file, i guess the way i would try to do it is, if the file is big enough, read the file size of the new file against the original, make a bit of math for percentage and update the bar with guictrlsetdata, otherwise the transfer is instant and the bar doesn't make sense. Edited August 12, 2018 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Developers Jos Posted August 12, 2018 Developers Share Posted August 12, 2018 Moved to the appropriate forum. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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