Sign in to follow this  
Followers 0
Rewl

Am I going right direction with Backups

4 posts in this topic

#1 ·  Posted (edited)

This is my fourth day programming in Auto-It so I'm still new, but I'm trying to make a program for my schools tech support team, where They run it than they can back up the current computers files to the H:\ Drive (Network Drive for that user)

Is this the right direction?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Back-Up by Rewl", 393, 288, 192, 124)
Global $Button1 = GUICtrlCreateButton("Backup to H:/", 120, 16, 131, 57, $WS_GROUP)
Global $Checkbox1 = GUICtrlCreateCheckbox("Favorites", 16, 96, 97, 17)
Global $Checkbox2 = GUICtrlCreateCheckbox("Desktop", 16, 120, 97, 17)
Global $Checkbox3 = GUICtrlCreateCheckbox("Music", 16, 144, 97, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $Button1
            DirCreate("H:\Back Up")
            If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then DirCopy(@FavoritesDir , "H:\Back Up")
            

    EndSwitch
Edited by Rewl

[size="1"]Programs: Draw Tool | [/size]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Something like this is a start...

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Back-Up by Rewl", 393, 288, 192, 124)
Global $Button1 = GUICtrlCreateButton("Backup to H:/", 120, 16, 131, 57, $WS_GROUP)
Global $Checkbox1 = GUICtrlCreateCheckbox("Favorites", 16, 96, 97, 17)
Global $Checkbox2 = GUICtrlCreateCheckbox("Desktop", 16, 120, 97, 17)
Global $Checkbox3 = GUICtrlCreateCheckbox("Music", 16, 144, 97, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Do
    $msg = GUIGetMsg()
    If $msg = $Button1 Then
        DirCreate("H:\Back Up")
        If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then ConsoleWrite ( "DirCopy Favorites " & @Crlf )
        If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then ConsoleWrite ( "DirCopy Desktop " & @Crlf )
        If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then ConsoleWrite ( "DirCopy Music " & @Crlf )
    EndIf
Until $msg = $GUI_EVENT_CLOSE

you could try with GUICtrlCreateRadio instead of GUICtrlCreateCheckbox

and DirCopy has a flag for overwrite files !

Can be usefull for a Backup...Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You are not reading the checkbox the right way, see GUICtrlRead() in the helpfile.

Also that DirCreate() looks unnecessary. Again, see helpfile for DirCopy().

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

okay thanks for the help guys!


[size="1"]Programs: Draw Tool | [/size]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0