Slydragon37 Posted March 7, 2010 Share Posted March 7, 2010 Hi, I'm kind of new to AutoIt and I need some help.I need a script that can be run on any computer (for use on a large network) and that will allow a non-computer "geek" to back up their files. What I'm thinking of is something that has multiple check boxes:DocumentsFiles on desktopiTunes musicAll .docFavorites in Firefox and Internet ExplorerThe user will be able to check the check box for whatever they would like to back up and it will create a folder inside the user's network server folder and zip it up. This will also need to be able to run on Windows XP and Macs. The user's server folder is -- H:\user's name\ -- and I want to move the files into -- H:\user's name\Back Up\ -- as a zip file. So how can I have the script check to see what check box is checked and gather all files (not applications) in whatever area specified. In addition, I've been looking online for something that can do this and was unable to find anything that recognizes different users and changes based on it (@ComputerName anyone?). But one thing I've noticed is that a lot of the scripts start with something like "#include <GUIConstantsEx.au3>" and usually "Opt('MustDeclareVars', 1)" but I am lost here and I don't know where the author of this script is getting those values. I've gotten a little bit into the manual and so far nothing has mentioned this and the GUI, Macro, and Function references online are no help. In addition the computer I am working with at school won't let me view the Keyword reference. Can someone please explain what these functions do and where I might find a list that I could refer to. Thanks.-SlydragonP.S. Do If..Then functions also need the ..Else..ElseIf and does every If..Then function if it is nested inside another If..Then need a separate EndIf or do I just need one for the outer If..Then? Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted March 7, 2010 Share Posted March 7, 2010 Hi and Welcome to the forum! Just use the helpfile you got with the download, press F1 to open it from SciTE (only works when an AutoIt file is opened) or by launching AutoIt.chm. Please have a look at the functions/keywords you are unsure off, and if you have any questions, you know where to find us! .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Slydragon37 Posted March 11, 2010 Author Share Posted March 11, 2010 Bump please! Link to comment Share on other sites More sharing options...
Skruge Posted March 11, 2010 Share Posted March 11, 2010 Welcome to the forums!- AutoIt won't run natively in Mac OS, so you're on your own there.- You'll need to create your own GUI with checkboxes- Differentiating users should be done with @UserName rather than (or in addition to) @ComputerName.Now that you mention it, the Keyword Reference table in my help file is empty. (I'm running 3.3.4.0 on my main box, 3.3.0.0 on another, which looks ok)However, I'm still able to expand the tree and get to the individual topics properly.Are you able to expand the tree? Is anyone else experiencing this issue?Either way, the documentation is also available online: http://www.autoitscript.com/autoit3/docs/If you get stuck, post the code you have so far.Good luck! [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted March 11, 2010 Share Posted March 11, 2010 The Keyword section for 3.3.4.0 is bugged yes, but it was fixed in the beta following it, and still works in 3.3.6.0. P.S. You really should update. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Slydragon37 Posted March 14, 2010 Author Share Posted March 14, 2010 I've already devised a system to create a GUI with the check boxes I want, but I just need help with the code to check for the specified check box(es) when a button is clicked. Here is the one I'm working on right now (very basic): expandcollapse popup#include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $button_1, $group_1, $check_1, $check_2, $check_3, $check_4 Local $radioval1, $radioval2, $msg Opt("GUICoordMode", 1) GUICreate("@ComputerName File Back Up", 400, 280) ; Create the controls $button_1 = GUICtrlCreateButton("Back Up to H:\", 30, 20, 120, 40) $group_1 = GUICtrlCreateGroup("Files", 30, 90, 165, 160) GUIStartGroup() $check_1 = GUICtrlCreateCheckbox("Desktop", 50, 120, 70, 20) $check_2 = GUICtrlCreateCheckbox("Documents", 50, 150, 80, 20) $check_3 = GUICtrlCreateCheckbox("Favorites", 50, 180, 80, 20) $check_4 = GUICtrlCreateCheckbox("iTunes Music", 50, 210, 80, 20) ; Show GUI GUISetState() ; In this message loop we use variables to keep track of changes to the radios, another ; way would be to use GUICtrlRead() at the end to read in the state of each control While 1 $msg = GUIGetMsg() Select Case $msg = $button_1 DirCreate("H:\Back Up") If GUICtrlRead($check_1) = $GUI_CHECKED Then DirCopy(@DesktopDir, "H:\Back Up") ElseIf If GUICtrlRead($check_2) = $GUI_CHECKED Then DirCopy(@MyDocumentsDir, "H:\Back Up") If GUICtrlRead($check_3) = $GUI_CHECKED Then DirCopy(@FavoritesDir, "H:\Back Up") If GUICtrlRead($check_4) = $GUI_CHECKED Then DirCopy("C:\Documents and Settings\@UserName\My Documents\My Music\iTunes Music", "H:\Back Up") EndIf EndIf EndIf EndIf MsgBox(0, "Finished", "Files backed up." & $radioval1) Case $msg >= $check_1 And $msg <= $check_3 $radioval1 = $msg - $check_1 EndSelect WEnd EndFunc But the problem is here, do I need an EndIf for every If..Then statement? In addition, does it matter what line the If..Then statements are on? I assumed they had to be on the same line since tested it on different lines bugged it out, but I see a lot of scripts that do have them on different lines (wrapping text maybe?). Also, do I need to have ElseIf statements nested within my If..Then for it to work? And the "#include.." at the top, where is the program getting this? What are they? What does that one do? Note: This script was copied from the "GUICtrlCreateRadio example" and various variables were changed and main script was changed to fit my intentions. There is another script that I looked up online and I'm trying to figure out how it works. Note: Not that I should copy it and put my own script in, but how it works so that I may create another script such as this from scratch in the future. Here it is: expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 315, 120, 193, 122) $Checkbox1 = GUICtrlCreateCheckbox("a", 8, 0, 25, 41) $Checkbox2 = GUICtrlCreateCheckbox("b", 8, 38, 25, 25) $Checkbox3 = GUICtrlCreateCheckbox("c", 8, 68, 25, 17) $Checkbox4 = GUICtrlCreateCheckbox("d", 8, 98, 25, 17) $Button1 = GUICtrlCreateButton("Alle Makieren", 48, 24, 121, 25, 0) $Button2 = GUICtrlCreateButton("Keine markieren", 48, 72, 121, 25, 0) $Button3 = GUICtrlCreateButton("Start", 176, 24, 121, 25, 0) $Button4 = GUICtrlCreateButton("Beenden", 176, 72, 121, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetState($Checkbox1, $GUI_CHECKED) GUICtrlSetState($Checkbox2, $GUI_CHECKED) GUICtrlSetState($Checkbox3, $GUI_CHECKED) GUICtrlSetState($Checkbox4, $GUI_CHECKED) Case $Button2 GUICtrlSetState($Checkbox1, $GUI_UNCHECKED) GUICtrlSetState($Checkbox2, $GUI_UNCHECKED) GUICtrlSetState($Checkbox3, $GUI_UNCHECKED) GUICtrlSetState($Checkbox4, $GUI_UNCHECKED) Case $Button3 If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then Sleep(2000) Send("{a}") ElseIf GUICtrlRead($Checkbox1) = $GUI_UNCHECKED Then Sleep(1) If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then Sleep(2000) send("{b}") ElseIf GUICtrlRead($Checkbox1) = $GUI_UNCHECKED Then Sleep(1) If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then Sleep(2000) Send("{c}") ElseIf GUICtrlRead($Checkbox1) = $GUI_UNCHECKED Then Sleep(1) EndIf EndIf EndIf Case $Button4 Exit EndSwitch WEnd Please help. And I would be grateful if you can also help me understand what is going on here. Thanks. -Sly P.S. In the first script I have the path set as "@UserName" but since it is within the " " for the path flag, it is not working as intended and is instead using the path as "..ettings\@UserName\My.." and not "..ettings\johnsonbh\My.." (network login ID for this explain would be Henry B Johnson). How may I fix this particular issue in addition to the above scripts and questions. Link to comment Share on other sites More sharing options...
omikron48 Posted March 15, 2010 Share Posted March 15, 2010 (edited) This makes a string having the stated value. "C:\Documents and Settings\@UserName\My Documents\My Music\iTunes Music" This makes a string with the @UserName macro inserted. "C:\Documents and Settings\" & @UserName & "\My Documents\My Music\iTunes Music" See the difference? The @UserName will not evaluate if you stick it directly inside quotations, not by default. GUIConstantsEx.au3 is a file used by the GUICtrl* functions, that's why it needs to be included. You can find it inside the Include folder in your AutoIt installation folder. "#include" includes the stated files when your script is compiled, adding the code inside those files with your code. Opt("MustDeclareVars", 1) is used to change settings in AutoIt. In this case, it is making it so that all variables must be declared before they are used. This is good practice to use because it helps simplify the process of debugging by eliminating the possibility of use of undeclared variables. BTW, all this information is in the help file. Edited March 15, 2010 by omikron48 Link to comment Share on other sites More sharing options...
Slydragon37 Posted March 18, 2010 Author Share Posted March 18, 2010 Ah, thank you, that clears some things up a bit.Also, I was looking in the help file and still cannot seem to find a command that let's me copy only documents of a selected directory. Does DirCopy take applications by default or is it set up to pull everything? So if the user has games, .exe, files (.doc/.ppt/.. etc.), and install files, how can I tell it to take only the "files"?-Sly Link to comment Share on other sites More sharing options...
omikron48 Posted March 18, 2010 Share Posted March 18, 2010 I'm not sure but I don't think filtered copy is provided in the AutoIt library. I looks like you need to make a function of your own or look for one in the forums. If you're planning on making one of your own, I recommend looking up FileFindFirstFile and FileFindNextFile for iterating through files/folders in a directory, and StringRegExp or StringCompare and StringRight to check whether a file ends in a particular file extension. 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