JohnRichard Posted August 11, 2008 Share Posted August 11, 2008 Hi to All! Yesterday i was able to made a sample backup script with checkboxes options but it is not yet complete. I finished with backing up Favorites folder. I wanted to enhance the script so that i will have a progress bar while the program is copying all the files and it will give me message soon as copying has finished. Need your expert programming skills on my script. Here is the sample code of the script: #NoTrayIcon #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GuiEdit.au3> #include <File.au3> Global $path Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form=C:\Documents and Settings\jyumul\Desktop\auTO3\samples\BackUp\Backup_new.kxf $Form1 = GUICreate("Backup", 491, 377, 204, 406) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore") $Group1 = GUICtrlCreateGroup("Select Folder to Backup", 48, 75, 393, 126) $Documents_Checkbox = GUICtrlCreateCheckbox("My Documents", 72, 115, 97, 25) GUICtrlSetOnEvent($Documents_Checkbox, "Documents_CheckboxClick") $Favorites_Checkbox = GUICtrlCreateCheckbox("Favorites", 72, 157, 97, 25) GUICtrlSetOnEvent($Favorites_Checkbox, "Favorites_CheckboxClick") $Desktop_CheckBox = GUICtrlCreateCheckbox("Desktop", 310, 115, 97, 25) GUICtrlSetOnEvent($Desktop_CheckBox, "Desktop_CheckBoxClick") $Outlook_CheckBox = GUICtrlCreateCheckbox("MS Outlook", 310, 157, 97, 25) GUICtrlSetOnEvent($Outlook_CheckBox, "Outlook_CheckBoxClick") GUICtrlCreateGroup("", -99, -99, 1, 1) $Edit = GUICtrlCreateEdit("", 48, 240, 393, 65) GUICtrlSetOnEvent(-1, "Change") $Backup_Button = GUICtrlCreateButton("Backup", 104, 328, 113, 33, 0) GUICtrlSetFont($Backup_Button, 8, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent($Backup_Button, "Backup_Buttonclick") $Exit_Button = GUICtrlCreateButton("Exit", 276, 328, 113, 33, 0) GUICtrlSetFont($Exit_Button, 8, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent($Exit_Button, "Exit_Buttonclick") $Backup_Label = GUICtrlCreateLabel("Backup Location:", 50, 26, 104, 17) GUICtrlSetFont($Backup_Label, 8, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent($Backup_Label, "Backup_LabelClick") $Browse_Button = GUICtrlCreateButton("Browse", 351, 12, 89, 33, 0) GUICtrlSetFont($Browse_Button, 8, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent($Browse_Button, "Browse_Buttonclick") $Input = GUICtrlCreateInput("", 160, 23, 185, 21) GUICtrlSetOnEvent(-1, "Change") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $Documents = GUICtrlRead($Documents_Checkbox) $Favorites = GUICtrlRead($Favorites_Checkbox) $Desktop = GUICtrlRead($Desktop_CheckBox) $Outlook = GUICtrlRead($Outlook_CheckBox) $mainwindow = GUIGetMsg() Switch $mainwindow Case $GUI_EVENT_CLOSE Exit_Buttonclick() Case $Backup_Button Backup_Buttonclick() EndSwitch WEnd Func Backup_Buttonclick() GUICtrlSetData($Edit, "Please wait while data is being backup...." & @CRLF & @CRLF, 1) Favorites_CheckboxClick() ;ProgressOn("Progress", "Backing up your data.", "0 percent complete" GUICtrlSetData($Edit, "Backup is complete!" & @CRLF, 1) EndFunc Func Backup_LabelClick() EndFunc Func Browse_Buttonclick() $path = FileSelectFolder("Choose folder for your backup", "", 1) GUICtrlSetData($Input, $path) EndFunc Func Change() EndFunc Func Desktop_CheckBoxClick() EndFunc Func Documents_CheckboxClick() Local $my_documents = @MyDocumentsDir Local $Folder_Array = _FileListToArray($my_documents & "\", "*", 2) Select Case $Documents = GUICtrlRead($Documents_Checkbox) If $Documents = $GUI_CHECKED Then DirCreate($path & "\My Documents Backup") DirCopy($my_documents, $path & "\My Documents Backup") EndIf EndSelect EndFunc Func Exit_Buttonclick() Exit EndFunc Func Favorites_CheckboxClick() Local $Favorites_path = @UserProfileDir & "\Favorites" Select Case $Favorites = GUICtrlRead($Favorites_Checkbox) If $Favorites = $GUI_CHECKED Then DirCreate($path & "\Favorites Backup") $copy = DirCopy($Favorites_path, $path & "\Favorites Backup", 1) ;GUICtrlSetData($Edit, & @CRLF "You selected Favorites") ;Else ;GUICtrlSetData($Edit, " EndIf EndSelect EndFunc Func Form1Close() Exit EndFunc Func Form1Maximize() EndFunc Func Form1Minimize() EndFunc Func Form1Restore() EndFunc Func Outlook_CheckBoxClick() EndFunc Link to comment Share on other sites More sharing options...
JohnRichard Posted August 11, 2008 Author Share Posted August 11, 2008 can anyone help me here? if not can someone give me sample script of copy with progress bar so that i can pattern it and pu it on my script.. appreciate all your help Link to comment Share on other sites More sharing options...
JohnRichard Posted August 11, 2008 Author Share Posted August 11, 2008 please i'm a totally newbie in AutoIt. Its just a learning from posting here in this forum. don't know which set of script i will use for progress bar i have read ProgressOn, ProgressSet but i don't know how will i use it and how to define the counters for progress... please help Link to comment Share on other sites More sharing options...
Triblade Posted August 11, 2008 Share Posted August 11, 2008 I dont't think you can use a progressbar if you can't get values. And I don't think you can get progress values from DirCopy... This command returns 1 or 0 and you can always If .. Then to check those to give you a MsgBox. The best you can do in my opinion is to check the size of the things to be copied and use a formula to think of the time the copy would likely take. My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
Triblade Posted August 12, 2008 Share Posted August 12, 2008 Well, to correct myself, I have seen this recently:http://www.autoitscript.com/forum/index.php?showtopic=44485This script compares the source and destination size. My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
JohnRichard Posted August 13, 2008 Author Share Posted August 13, 2008 i see. coz i'm totally newbie here. i don't know how to compare values. maybe i need to read on some sample script. so how will it give me progress status while the script is copying a file(s) or folders. Link to comment Share on other sites More sharing options...
Triblade Posted August 13, 2008 Share Posted August 13, 2008 (edited) See that link in my previous post? Click it. Then copy the code into your script at the bottom. Then use this line to copy stuff and set the progress in a label: _CopyDirectoryWithProgress($source, $destination, $update_label) Fill $source with the thing to copy. Fill $destination with the path to copy to. Fill $update_label with the label to set the copy progress. Change the function to get it to work with a progress bar, but if you can't code stick with this and the label. P.S. It's a xcopy. Look that up if you don't know what that is. Edited August 13, 2008 by Triblade My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
JohnRichard Posted August 13, 2008 Author Share Posted August 13, 2008 thanks a lot. i'll give it a try. Link to comment Share on other sites More sharing options...
Triblade Posted August 13, 2008 Share Posted August 13, 2008 thanks a lot. i'll give it a try.Good. Good luck.Any questions? Post them in that thread My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
JohnRichard Posted August 13, 2008 Author Share Posted August 13, 2008 yap. i have another question. whew, as i learn into codes, i'm getting more stucked to what i will write on my script. i have this script which pings a computer and if its online it will execute a program (an AUTOIT script compiled to exe. My problem is, how will i execute the exe on the remote computer. I got the script working on my local computer but not on the remote computer. Please help and check my script. Don't know which code it is. here is my code: #NoTrayIcon #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GuiEdit.au3> #include <File.au3> Opt("GUIOnEventMode", 1) Global $Form1 = GUICreate("Computer", 506, 314, 201, 346) GUISetOnEvent($GUI_EVENT_CLOSE, "Button3Click") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore") Global $Label1 = GUICtrlCreateLabel("PC Name / IP Address", 18, 28, 131, 17) GUICtrlSetFont($Label1, 9, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent($Label1, "Label1Click") Global $Input = GUICtrlCreateInput("", 153, 24, 209, 21) GUICtrlSetOnEvent(-1, "Change") Global $Computer_Button = GUICtrlCreateButton("Check Computer", 377, 22, 105, 25, 0) GUICtrlSetFont($Computer_Button, 8, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent($Computer_Button, "Check_Computer_Button_Click") Global $Temp_Checkbox = GUICtrlCreateCheckbox("Delete Temp Files", 89, 88, 105, 17) GUICtrlSetOnEvent($Temp_Checkbox, "Checkbox1Click") Global $EndPoint_Checkbox = GUICtrlCreateCheckbox("Install Endpoint", 257, 88, 113, 17) GUICtrlSetOnEvent($EndPoint_Checkbox, "Checkbox2Click") Global $Edit = GUICtrlCreateInput("", 55, 144, 401, 80, $ES_READONLY) GUICtrlSetOnEvent(-1, "Change") Global $GO_Button = GUICtrlCreateButton("GO", 296, 256, 81, 33, 0) GUICtrlSetFont($GO_Button, 9, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent($GO_Button, "GO_Button_Click") Global $Exit_Button = GUICtrlCreateButton("Exit", 401, 256, 82, 33, 0) GUICtrlSetFont($Exit_Button, 9, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent($Exit_Button, "Button3Click") GUISetState(@SW_SHOW) While 1 $Form1 = GUIGetMsg() Switch $Form1 Case $GUI_EVENT_CLOSE Button3Click() EndSwitch WEnd Func Check_Computer_Button_Click() Local $check_computer = GUICtrlRead($Input) $ping = Ping($check_computer, 1000) If $ping Then GUICtrlSetData($Edit, "Computer is ONLINE") Else SoundPlay(@WindowsDir & "\media\Windows XP Hardware Fail.wav",1) ;SoundPlay(@WindowsDir & "\media\tada.wav",1) ;MsgBox(16, "", "Computer cannot be located. Either it is OFFLINE or DISCONNECTED.") GUICtrlSetData($Edit, "Computer cannot be located. Either it is OFFLINE or DISCONNECTED.") If $check_computer = "" Then ;SoundPlay(@WindowsDir & "\media\Windows XP Hardware Fail.wav",1) GUICtrlSetData($Edit, "") GUICtrlSetData($Edit, "No computer specified. Please type PC Name or IP Address.") EndIf EndIf EndFunc Func GO_Button_Click() Local $check_computer = GUICtrlRead($Input), $filepath = "\\test\sample$\Clean-Up.exe", $destination = $check_computer & @SystemDir If $check_computer = "" Then GUICtrlSetData($Edit, "No computer specified. Please type PC Name or IP Address.") Else GUICtrlSetData($Edit, "" & @CRLF) GUICtrlSetData($Edit, "Performing action on computer............" & @CRLF & @CRLF, 1) FileInstall($filepath, $destination , 1) Run("Clean-Up.exe", $check_computer & @SystemDir) GUICtrlSetData($Edit, "Task(s) completed!" & @CRLF, 1) If $check_computer <> "04" And "10.14." Then GUICtrlSetData($Edit, "Cannot perform action!") $ping2 = Ping($check_computer, 3000) If $ping2 Then GUICtrlSetData($Edit, "" & @CRLF) GUICtrlSetData($Edit, "Performing action on computer............" & @CRLF & @CRLF, 1) Run("Notepad.exe", @SystemDir) ;FileInstall($filepath, $destination , 1) GUICtrlSetData($Edit, "Task(s) completed!" & @CRLF, 1) Else GUICtrlSetData($Edit, "Cannot perform action! Either the PC or IP Address is invalid.") EndIf EndIf EndIf EndFunc Func Button3Click() Exit EndFunc Func Change() EndFunc Func Checkbox1Click() EndFunc Func Checkbox2Click() EndFunc Func Form1Maximize() EndFunc Func Form1Minimize() EndFunc Func Form1Restore() EndFunc Func Label1Click() EndFunc Link to comment Share on other sites More sharing options...
therks Posted August 13, 2008 Share Posted August 13, 2008 That seems like a completely unrelated question to original topic. Either start a new thread with the new question, or explain how it relates to the initial topic. You shouldn't tack on new, unrelated questions to existing topics, it just gets confusing. Not trying to pick on you, just trying to advise. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
JohnRichard Posted August 18, 2008 Author Share Posted August 18, 2008 oops. i should have posted it it a new thread. anyways i got it working using PSEXEC and RUN command i was able to make the script working. thanks for the help. 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