Jump to content

Updater_full


Gyzmok
 Share

Recommended Posts

This tool is a newer/better version of my previous : Updaterv1.0

Updater_full is a tool that can execute a number of update or backup tasks, allowing

"Scheduled Tasks", running in the background, running with command-line options and

logging of each action.

Possible use :

- update/copy/backup your autoitscripts,pictures,.mp3,.avi folders on an external harddisk or

memory stick.

- make regular/scheduled backup copies of your important data to external (virtual) drives.

- prepare an "upload" folder that contains only "newer files" that needs to be uploaded to your website.

http://www.autoitscript.com/fileman/users/Gyzmok/updater_full20.jpg

History

-------

- Updater v2.0

Added logging + log menu

Added run in hidden window + command-line options

- Updater v1.7

Added option to change file time compare precision.

Minor bugfixes.

- Updater v1.6

Added option menu

Added Taskinfo

- Updater v1.5

check the Source and Destination path to make sure they are not the same.

Added menu items

Newer .ini file recovers data from previous version of the .ini file.

- Updater v1.4

Changed the .ini file from static to dynamic growing and shrinking.

Removed buttons on the GUI and added menu items instead.

- Updater v1.3

The .ini file full of "-1" problem should be solved now by using Gafrost's GuiListView v1.63 include

Added : when message "Skipping this update : Source drive not ready" the program continues after 10 seconds.

- Updater v1.2

Corrected : the subdir from a "non-checked" file was wrongfully created on the destination drive.

Added the "Config" menu to set a default source/destination drive or directory.

Added a source/destination drive status check.(drive must be "READY")

Added a FAT/NTFS drive filesystem check : if no FAT drive is involved, file compare

time accuracy is up to the second.

Display the source dir in the listview immediately after it is choosen from

the dir selector box.

- Updater v1.1

The message "The source file is older than the destination file" will not appear if

the difference is less than 3 seconds.

To Ignore the FAT/NTFS timestamp issues of "2 second difference".

#include <GuiConstants.au3>
#include <GuiListView.au3>
#include <Misc.au3>
#include <string.au3>
#include <File.au3>
; AUTOIT v3.2.1.14 (beta) or higher required to compile
;
;Updater_full is a tool that can execute a number of update or backup tasks, allowing
;"Scheduled Tasks", running in the background, running with command-line options and
;logging of each action.
;
; Possible use :

; - update/copy/backup your autoitscripts,pictures,.mp3,.avi folders on an external harddisk or
;   memory stick.
; - make regular/scheduled backup copies of your important data to external (virtual) drives.
; - prepare an "upload" folder that contains only "newer files" that needs to be uploaded to your website.
;
; command-line options :
;
; C:\Updaterv2.0\updater_full.exe /silent
; C:\Updaterv2.0\updater_full.exe /silent /all
; C:\Updaterv2.0\updater_full.exe /silent 1 2 3
;
; for more info : see updater_full_readme.txt
; Guy Tackaert - 2006/2007
;$version = "v2.0   by  X1GTT - press ESC to quit"
$version = "v2.0"
;global $applpath = "C:\bat\"
global $applpath = @ScriptDir&"\"
;
dim $failure = 0
;
global $log = 0
$log = Iniread($applpath&"Updater.ini","OPTIONS", "Log",1) 
;
global $backgnd = 0
global $all = 0
global $some = 0
;check if run with parameters
IF  $CmdLine[0] > 0 Then
    if  StringLower($CmdLine[1]) = "/silent" Then
        $backgnd = 1
    EndIf
    if  $CmdLine[0] > 1 Then
        if  StringLower($CmdLine[2]) = "/all" Then
            $all = 1
        Else
            $some = 1
            global $param[$CmdLine[0]]
            if  not _fill_paramlist() Then
                if  $backgnd = 0 then
                    MsgBox(0,"Error","Error in parameters see readme.txt")
                Else
                    if  $log > 0 Then
                        _log_parameters()
                        LogEvent(3,$log,"Error in parameters see readme.txt > Exit")
                    EndIf
                EndIf
                Exit
            EndIf
        EndIf
    EndIf
EndIf
;MsgBox(0,"test","past parameters")
;
;check if prog is still/already running
if  _Singleton("updater_full.exe",1) = 0 Then
    if  $backgnd = 0 then
        Msgbox(0,"Warning","An occurence of updater_full.exe is already running > Exit")
        ;later enkel aanroepen als window slechts minimized is en niet in /silent draait
        ;WinSetState("Updater full "&$version, "", @SW_RESTORE )
    Else
        Msgbox(0,"Warning","An occurence of updater_full.exe is already running > Exit",2)
        if  $log > 0 Then
            LogEvent(3,$log,"An occurence of updater_full.exe is still running > Exit")
        EndIf
    EndIf
    Exit
EndIf
;
; if run in /silent with additional parameters, log the params
_log_parameters()
;
;make an .ini file 
if  not FileExists($applpath&"Updater.ini") Then
    IniWrite($applpath&"Updater.ini","VERSION", "Version","20")
    IniWrite($applpath&"Updater.ini","DEFAULT_DIRS", "Initsrc","")
    IniWrite($applpath&"Updater.ini","DEFAULT_DIRS", "Initdest","")
    IniWrite($applpath&"Updater.ini","OPTIONS", "Nosummary",0)
    IniWrite($applpath&"Updater.ini","OPTIONS", "Autoupdate",0)
    IniWrite($applpath&"Updater.ini","OPTIONS", "Precision",3)
    IniWrite($applpath&"Updater.ini","OPTIONS", "Nogui",0)
    IniWrite($applpath&"Updater.ini","OPTIONS", "Log",0)
    IniWrite($applpath&"Updater.ini","TASKS","active0","")
    IniWrite($applpath&"Updater.ini","TASKS","Task_name0","")
    IniWrite($applpath&"Updater.ini","TASKS","Task_source0","")
    IniWrite($applpath&"Updater.ini","TASKS","Task_destination0","")
    IniWrite($applpath&"Updater.ini","TASKS","Last_update0","")
EndIf
;recover the data from an older .ini file
if  FileExists($applpath&"Updater.ini") and IniRead ($applpath&"Updater.ini", "VERSION", "Version","NotFound") <> 20 Then
    if  FileCopy($applpath&"Updater.ini",$applpath&"Updater_temp~.ini",1) then
        FileDelete($applpath&"Updater.ini")
    Else
        $failure = 1
    EndIf
    if  $failure = 0 then
        IniWrite($applpath&"Updater.ini","VERSION", "Version","20")
        $tsrc = Iniread($applpath&"Updater_temp~.ini", "DEFAULT_DIRS", "Initsrc","")
        $tdest = Iniread($applpath&"Updater_temp~.ini", "DEFAULT_DIRS", "Initdest","")
        $old_nosum = Iniread($applpath&"Updater_temp~.ini","OPTIONS", "Nosummary",0)
        $old_auto = Iniread($applpath&"Updater_temp~.ini","OPTIONS", "Autoupdate",0)
        $old_prec = Iniread($applpath&"Updater_temp~.ini","OPTIONS", "Precision",3) 
        $old_nogui = Iniread($applpath&"Updater_temp~.ini","OPTIONS", "Nogui",0) 
        $old_log = Iniread($applpath&"Updater_temp~.ini","OPTIONS", "Log",0) 
        IniWrite($applpath&"Updater.ini","DEFAULT_DIRS", "Initsrc",$tsrc)
        IniWrite($applpath&"Updater.ini","DEFAULT_DIRS", "Initdest",$tdest)
        IniWrite($applpath&"Updater.ini","OPTIONS", "Nosummary",$old_nosum)
        IniWrite($applpath&"Updater.ini","OPTIONS", "Autoupdate",$old_auto)
        IniWrite($applpath&"Updater.ini","OPTIONS", "Precision",$old_prec)
        IniWrite($applpath&"Updater.ini","OPTIONS", "Nogui",$old_nogui)
        IniWrite($applpath&"Updater.ini","OPTIONS", "Log",$old_log)
        $nmbr = 0
        Do
            $Tsk_src = IniRead ($applpath&"Updater_temp~.ini","TASKS","Task_source"&$nmbr,"STOP")
            if  $Tsk_src <> "STOP" and $Tsk_src <> "" then
                $Tsk_name = IniRead ($applpath&"Updater_temp~.ini","TASKS","Task_name"&$nmbr,"Task"&$nmbr+1)
                $Tsk_dst = IniRead ($applpath&"Updater_temp~.ini","TASKS","Task_destination"&$nmbr,"STOP")
                $actv = IniRead ($applpath&"Updater_temp~.ini","TASKS","active"&$nmbr, 0)
                $Lst_upd = IniRead ($applpath&"Updater_temp~.ini","TASKS","Last_update"&$nmbr,"-")
                IniWrite($applpath&"Updater.ini","TASKS","active"&$nmbr,$actv)
                IniWrite($applpath&"Updater.ini","TASKS","Task_name"&$nmbr,$Tsk_name)
                IniWrite($applpath&"Updater.ini","TASKS","Task_source"&$nmbr,$Tsk_src)
                IniWrite($applpath&"Updater.ini","TASKS","Task_destination"&$nmbr,$Tsk_dst)
                IniWrite($applpath&"Updater.ini","TASKS","Last_update"&$nmbr,$Lst_upd)
            EndIf
            $nmbr = $nmbr + 1
        Until $Tsk_src = "STOP" or $Tsk_src = ""
        FileDelete($applpath&"Updater_temp~.ini")
    Else
        Msgbox(0+48,"Failure","Failed to recover old ini file")
    EndIf
EndIf
;
$myGUI =    GuiCreate("Updater full "&$version,1074, 597,(@DesktopWidth-1074)/2, (@DesktopHeight-565)/2 _
            ,$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
Dim $Button_launch, $shutdown = 0, $mylist, $upd = 0
Global  $Run1 = 0, $tosearch, $OverallQty, $Overall, $source, $overallpercent, $Progress0Text, _
        $progressbar1, $Progress1Text, $progressbar2, $Progress2Text, $Gui,$Fat = 1,$add = 1,$cpopath, _
        $nmbr_newer = 0,$nmbr_changed = 0,$compare_active = 0,$compare_stop = 0,$nogui = 0
;
$mylist =   GUICtrlCreateListView("      |Taskname|Source drive/dir|Destination drive/dir|Last compared", 72, 48, 970, 160, _
            BitOR($LVS_SHOWSELALWAYS,$LVS_NOSORTHEADER, $LVS_REPORT), _
            BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT,$LVS_EX_CHECKBOXES, $LVS_EX_FLATSB ))
_GUICtrlListViewSetColumnWidth($mylist,0,47)
_GUICtrlListViewSetColumnWidth($mylist,1,153)
_GUICtrlListViewSetColumnWidth($mylist,2,330)
_GUICtrlListViewSetColumnWidth($mylist,3,270)
_GUICtrlListViewSetColumnWidth($mylist,4,150)
;
$mylist2 =  GUICtrlCreateListView("Source file|Destination file|Source date|Destination date|+/- MB|Taskname|Changed|Newer", 28, 263, 1014, 272, _
            BitOR($LVS_SHOWSELALWAYS,$LVS_NOSORTHEADER, $LVS_REPORT), _
            BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT,$LVS_EX_CHECKBOXES, $LVS_EX_FLATSB ))
_GUICtrlListViewSetColumnWidth($mylist2,0,335)
_GUICtrlListViewSetColumnWidth($mylist2,1,300)
_GUICtrlListViewSetColumnWidth($mylist2,2,146)
_GUICtrlListViewSetColumnWidth($mylist2,3,146)
_GUICtrlListViewSetColumnWidth($mylist2,4,67)
_GUICtrlListViewHideColumn($mylist2,5)
_GUICtrlListViewHideColumn($mylist2,6)
_GUICtrlListViewHideColumn($mylist2,7)
;
$Graphic1 = GUICtrlCreateGraphic(-1,-1, 1280, 1024)
GUICtrlSetBkColor($Graphic1, 0xDDDBCC)
GuiCtrlSetState($Graphic1,$GUI_DISABLE)
;
$filemenu = GUICtrlCreateMenu (" &File ")
$menu_add = GUICtrlCreateMenuitem ("Add a new Task. <INS>",$filemenu)
$menu_edit = GUICtrlCreateMenuitem ("Edit a selected Task.",$filemenu)
$menu_remove = GUICtrlCreateMenuitem ("Remove Task(s). <DEL>",$filemenu)
$sep1 = GUICtrlCreateMenuitem ("",$filemenu,3)
$menu_copy_to = GUICtrlCreateMenuitem ("Copy source file(s) to ...",$filemenu)
$sep2 = GUICtrlCreateMenuitem ("",$filemenu,5)
$menu_exit = GUICtrlCreateMenuitem (" Exit ",$filemenu)
$optionmenu = GUICtrlCreateMenu (" Options ")
;$modemenu = GUICtrlCreateMenu ("Mode",$optionmenu,1)
$precisionmenu = GUICtrlCreateMenu ("File time compare precision",$optionmenu,0)
$menu_prec_1 = GUICtrlCreateMenuitem ("1 second",$precisionmenu)
$menu_prec_3 = GUICtrlCreateMenuitem ("3 seconds",$precisionmenu)
$sep3 = GUICtrlCreateMenuitem ("",$optionmenu,2)
GUICtrlSetState($menu_prec_3,$GUI_CHECKED)
if  Iniread($applpath&"Updater.ini","OPTIONS", "Precision",3) = 1 Then
    GUICtrlSetState($menu_prec_3,$GUI_UNCHECKED)
    GUICtrlSetState($menu_prec_1,$GUI_CHECKED)
Else
    GUICtrlSetState($menu_prec_3,$GUI_CHECKED)
    GUICtrlSetState($menu_prec_1,$GUI_UNCHECKED)
EndIf
$menu_default = GUICtrlCreateMenuitem ("Set default source/destination dir",$optionmenu)
$sep4 = GUICtrlCreateMenuitem ("",$optionmenu,3)
$menu_summary = GUICtrlCreateMenuitem ("Don't show taskinfo after compare",$optionmenu)
if  Iniread($applpath&"Updater.ini","OPTIONS", "Nosummary",0) = 0 Then
    GUICtrlSetState($menu_summary,$GUI_UNCHECKED)
Else
    GUICtrlSetState($menu_summary,$GUI_CHECKED) 
EndIf
$menu_nogui = GUICtrlCreateMenuitem ("Don't show progressbar during compare",$optionmenu)
$sep5 = GUICtrlCreateMenuitem ("",$optionmenu,6)
if  Iniread($applpath&"Updater.ini","OPTIONS", "Nogui",0) = 0 Then
    $nogui = 0
    GUICtrlSetState($menu_nogui,$GUI_UNCHECKED)
Else
    $nogui = 1
    GUICtrlSetState($menu_nogui,$GUI_CHECKED)   
EndIf
$menu_fastupdate = GUICtrlCreateMenuitem ("Auto start update after compare",$optionmenu)
if  Iniread($applpath&"Updater.ini","OPTIONS", "Autoupdate",0) = 0 Then
    GUICtrlSetState($menu_fastupdate,$GUI_UNCHECKED)
Else
    GUICtrlSetState($menu_fastupdate,$GUI_CHECKED)  
EndIf
$logmenu = GUICtrlCreateMenu (" &Log ")
$menu_showlog = GUICtrlCreateMenuitem ("Show Log",$logmenu)
$sep6 = GUICtrlCreateMenuitem ("",$logmenu,2)
$logmenu_nolog = GUICtrlCreateMenuitem ("No logging",$logmenu)
$logmenu_basiclog = GUICtrlCreateMenuitem ("Basic logging",$logmenu)
$logmenu_detaillog = GUICtrlCreateMenuitem ("Detailed logging",$logmenu)
GUICtrlSetState($logmenu_basiclog,$GUI_CHECKED)
if  Iniread($applpath&"Updater.ini","OPTIONS", "Log",1) = 0 Then
    $log = 0
    GUICtrlSetState($logmenu_nolog,$GUI_CHECKED)
    GUICtrlSetState($logmenu_basiclog,$GUI_UNCHECKED)
    GUICtrlSetState($logmenu_detaillog,$GUI_UNCHECKED)
Elseif Iniread($applpath&"Updater.ini","OPTIONS", "Log",1) = 1 Then
    $log = 1
    GUICtrlSetState($logmenu_nolog,$GUI_UNCHECKED)
    GUICtrlSetState($logmenu_basiclog,$GUI_CHECKED)
    GUICtrlSetState($logmenu_detaillog,$GUI_UNCHECKED)
Elseif Iniread($applpath&"Updater.ini","OPTIONS", "Log",1) = 2 Then
    $log = 2
    GUICtrlSetState($logmenu_nolog,$GUI_UNCHECKED)
    GUICtrlSetState($logmenu_basiclog,$GUI_UNCHECKED)
    GUICtrlSetState($logmenu_detaillog,$GUI_CHECKED)
EndIf
$helpmenu = GUICtrlCreateMenu (" &Help ")
$menu_readme = GUICtrlCreateMenuitem ("Show Readme.txt",$helpmenu)


;
$Button_check1 = GuiCtrlCreateButton("v",72,20,22,22)
GUICtrlSetTip($Button_check1, "Check all")
$Button_uncheck1 = GuiCtrlCreateButton(" ",97,20,22,22)
GUICtrlSetTip($Button_uncheck1, "Uncheck all")
;
;$Group1 = GUICtrlCreateGroup("", 8, 0, 1056, 526)
;
;$Button_add = GuiCtrlCreateButton("Add",500,15, 45, 27)
;GUICtrlSetTip($Button_add, "Add an update Task to the list. <INS>")
;GUIctrlsetState($Button_add,$GUI_FOCUS + $GUI_DEFBUTTON)
;$Button_edit = GuiCtrlCreateButton("Edit", 550,15, 45, 27)
;GUICtrlSetTip($Button_edit, "Edit a selected Task")
;$Button_remove = GuiCtrlCreateButton("Remove", 600,15, 75, 27)
;GUICtrlSetTip($Button_remove, "Remove one or more update Task(s) from the list. <DEL>")
$Button_launch = GuiCtrlCreateButton("Start compare", 483, 8, 100, 30)
GUICtrlSetTip($Button_launch, "Start comparing all files in the update Tasks from the list,")
$Button_up = GuiCtrlCreateButton("Up",28,86,33,37,$BS_ICON)
GUICtrlSetImage (-1, $applpath&"up.ico")
GUICtrlSetTip($Button_up, "Move up the selected Task")
$Button_down = GuiCtrlCreateButton("Down",28,130,33,37,$BS_ICON)
GUICtrlSetImage (-1, $applpath&"down.ico")
GUICtrlSetTip($Button_down, "Move down the selected Task")
;
$Button_check2 = GuiCtrlCreateButton("v",28,228,22,22)
GUICtrlSetTip($Button_check2, "Check all")
$Button_uncheck2 = GuiCtrlCreateButton(" ",53,228,22,22)
GUICtrlSetTip($Button_uncheck2, "Uncheck all")
$Button_compare =GUICtrlCreateButton ("Compare Code",483, 228, 100, 22)
GUICtrlSetTip($Button_compare, "Select one file and compare the code of the source file with the code of the destination file" _
                    &@lf&".fmb and .rdf only  (uses FormsApiMaster) ")
if  $applpath <> "C:\bat\" Then
    GUICtrlSetState($Button_compare,$GUI_HIDE)
EndIf
;
$button_count = GuiCtrlCreateButton("Show taskinfo", 28, 530, 100, 22)
GUICtrlSetTip($button_count, "Recalculate detailed taskinfo.")
$Button_Update = GuiCtrlCreateButton("Start Update", 475, 530, 120, 30)
GUICtrlSetTip($Button_Update, "Start updating all the ""checked"" files in the above list.")
;$Button_cancel = GuiCtrlCreateButton("Cancel",565,530,90,30)
;GUICtrlSetTip($Button_cancel, "Exit Updater")
;
;
HotKeySet("{ESC}", "_ExitUpdater")
Func _ExitUpdater()
    if  $compare_active = 1 Then
        LogEvent(1,$log,"Compare interrupted by user")
        $compare_stop = 1
    Else
        GUISetCursor(2)
        _iniwrite()
        LogEvent(1,$log,"Program interrupted by user")
        Exit
    EndIf
EndFunc
;
Global $initsrc = Iniread($applpath&"Updater.ini", "DEFAULT_DIRS", "Initsrc","")
Global $initdest = Iniread($applpath&"Updater.ini", "DEFAULT_DIRS", "Initdest","")
;
; read the ini file until empty
Do
    $Task_name = IniRead ($applpath&"Updater.ini", "TASKS", "Task_name" & $upd, "")
    $Task_source = IniRead ($applpath&"Updater.ini", "TASKS", "Task_source" & $upd, "STOP")
    if  $Task_source <> "STOP" and $Task_source <> "" then
        $Task_destination = IniRead ($applpath&"Updater.ini", "TASKS", "Task_destination"& $upd, "STOP")
        $active = IniRead ($applpath&"Updater.ini", "TASKS", "active"& $upd, 0)
        $Last_update = IniRead ($applpath&"Updater.ini", "TASKS", "Last_update"& $upd,"-")
        _GUICtrlListViewInsertItem ($mylist, $upd,($upd+1)&"|"&$Task_name&"|"&$Task_source&"|"&$Task_destination&"|"&$Last_update)
        if $backgnd = 1 and $some = 1 Then
            if  _check_task_in_para($upd+1) Then
                _GUICtrlListViewSetCheckState($mylist, $upd)
            EndIf
        Else
            if  $active = 1 or ($backgnd = 1 and $all = 1) then
                _GUICtrlListViewSetCheckState($mylist, $upd)
            EndIf
        EndIf
    EndIf
    $upd = $upd + 1
Until $Task_source = "STOP" or $Task_source = ""
_setbut()
;
;MsgBox(0,"window",WinGetState("Updater full "&$version, ""))
;autorun in /silent mode
if  $backgnd = 1 then
    LogEvent(1,$log,"/silent mode")
    $nogui = 1
    WinSetState("Updater full "&$version, "", @SW_HIDE)
    if  _checkbox_active($mylist) = 1 then
        ;_iniwrite()
        _start_tasks()
        ;_setbut()
        if  _checkbox_active($mylist2) = 1 then
            _update()
            ;_setbut()
        Else
            LogEvent(1,$log,"Compare Done - no differences found")
        EndIf
    EndIf
    MsgBox(0,"Updater full "&StringLeft($version,5),"silent mode done",5)
    Exit
EndIf
;
;
SplashOff ( )
$dll = DllOpen("user32.dll")
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE or $msg = $menu_exit
                _iniwrite()
                Exit
        Case $msg = $menu_default
                _change_default_source_dest_dir()
        Case $msg = $menu_add
                $add = 1
                _add_edit()
        Case $msg = $menu_edit
                $add = 0
                _add_edit()
        Case $msg = $menu_remove
                _remove()
        Case $msg = $menu_copy_to
                _copy_to()
        Case $msg = $menu_summary
                if  BitAND(GUICtrlRead($menu_summary), $GUI_CHECKED) then 
                    GUICtrlSetState($menu_summary,$GUI_UNCHECKED)
                    IniWrite($applpath&"Updater.ini","OPTIONS", "Nosummary",0)
                else 
                    GUICtrlSetState($menu_summary,$GUI_CHECKED)
                    IniWrite($applpath&"Updater.ini","OPTIONS", "Nosummary",1)                  
                EndIf
        Case $msg = $menu_nogui
                if  BitAND(GUICtrlRead($menu_nogui), $GUI_CHECKED) then 
                    GUICtrlSetState($menu_nogui,$GUI_UNCHECKED)
                    $nogui = 0
                    IniWrite($applpath&"Updater.ini","OPTIONS", "Nogui",0)
                else 
                    GUICtrlSetState($menu_nogui,$GUI_CHECKED)
                    $nogui = 1
                    IniWrite($applpath&"Updater.ini","OPTIONS", "Nogui",1)                  
                EndIf
        Case $msg = $menu_fastupdate
                if  BitAND(GUICtrlRead($menu_fastupdate), $GUI_CHECKED) then 
                    GUICtrlSetState($menu_fastupdate,$GUI_UNCHECKED)
                    IniWrite($applpath&"Updater.ini","OPTIONS", "Autoupdate",0)                 
                else 
                    GUICtrlSetState($menu_fastupdate,$GUI_CHECKED)
                    IniWrite($applpath&"Updater.ini","OPTIONS", "Autoupdate",1) 
                EndIf
        Case $msg = $menu_prec_1
                    GUICtrlSetState($menu_prec_1,$GUI_CHECKED)
                    GUICtrlSetState($menu_prec_3,$GUI_UNCHECKED)
                    IniWrite($applpath&"Updater.ini","OPTIONS", "Precision",1)
        Case $msg = $menu_prec_3
                    GUICtrlSetState($menu_prec_3,$GUI_CHECKED)
                    GUICtrlSetState($menu_prec_1,$GUI_UNCHECKED)
                    IniWrite($applpath&"Updater.ini","OPTIONS", "Precision",3)
        Case $msg = $logmenu_nolog
                    $log = 0
                    GUICtrlSetState($logmenu_nolog,$GUI_CHECKED)
                    GUICtrlSetState($logmenu_basiclog,$GUI_UNCHECKED)
                    GUICtrlSetState($logmenu_detaillog,$GUI_UNCHECKED)
                    IniWrite($applpath&"Updater.ini","OPTIONS", "Log",0)
        Case $msg = $logmenu_basiclog
                    $log = 1
                    GUICtrlSetState($logmenu_nolog,$GUI_UNCHECKED)
                    GUICtrlSetState($logmenu_basiclog,$GUI_CHECKED)
                    GUICtrlSetState($logmenu_detaillog,$GUI_UNCHECKED)
                    IniWrite($applpath&"Updater.ini","OPTIONS", "Log",1)
        Case $msg = $logmenu_detaillog
                    $log = 2
                    GUICtrlSetState($logmenu_nolog,$GUI_UNCHECKED)
                    GUICtrlSetState($logmenu_basiclog,$GUI_UNCHECKED)
                    GUICtrlSetState($logmenu_detaillog,$GUI_CHECKED)
                    IniWrite($applpath&"Updater.ini","OPTIONS", "Log",2)                        
        Case $msg = $Button_up
                    _upmove()
                    _iniwrite()
        Case $msg = $Button_down
                    _downmove()
                    _iniwrite()
        Case $msg = $Button_check1
                    _check_all($mylist)
                    _setbut()
        Case $msg = $Button_uncheck1
                    _uncheck_all($mylist)
                    _setbut()
        Case $msg = $Button_check2
                    _check_all($mylist2)
                    _setbut()
        Case $msg = $Button_uncheck2
                    _uncheck_all($mylist2)
                    _setbut()
        Case $msg = $menu_readme
                If  Not FileExists($applpath&"updater_full_readme.txt") Then 
                    MsgBox(0+16,"error","Readme.txt file not found")
                Else
                    Run("Notepad.exe " & $applpath&"updater_full_readme.txt", "", @SW_MAXIMIZE)
                EndIf
        Case $msg = $menu_showlog
                If  Not FileExists($applpath&@ComputerName&"_update_log.txt") Then
                    MsgBox(0+16,"error",$applpath&@ComputerName&"_update_log.txt file not found")
                Else
                    ;open the log with notepad.exe and go to the last log entry
                    Run("Notepad.exe " & $applpath&@ComputerName&"_update_log.txt", "", @SW_MAXIMIZE)
                    WinWaitActive(@ComputerName&"_update_log.txt")
                    Send("^{END}")
                EndIf
        Case $msg = $Button_launch
                $compare_stop = 0
                if  _checkbox_active($mylist) = 1 then
                    _iniwrite()
                    _start_tasks()
                    _setbut()
                    if  not _GUICtrlListViewGetItemCount ($mylist2) < 1 then
                        if  BitAND(GUICtrlRead($menu_summary), $GUI_CHECKED) = 0 _
                            and BitAND(GUICtrlRead($menu_fastupdate), $GUI_CHECKED) = 0 then 
                            _countMB()
                        Else
                            if  BitAND(GUICtrlRead($menu_fastupdate), $GUI_CHECKED) = 1 then 
                                if  _checkbox_active($mylist2) = 1 then
                                    GUISetCursor(15,1,$myGUI)
                                    _update()
                                    _setbut()
                                    GUISetCursor(2,1,$myGUI)
                                Else
                                    MsgBox(0+48,"","Please select one or more file(s)to update." _
                                            &@lf&@lf&"- Use the Checkboxes.")
                                EndIf
                            else
                                if  $compare_stop = 1 Then
                                    MsgBox(0+64,"Compare interrupted by user",$nmbr_changed&" changed file(s) found until stop." _
                                    &@lf&$nmbr_newer&" newer file(s) found until stop." _
                                    &@lf&@lf&"Use the 'Start Update' button to update the destination(s).  " _
                                    &@lf&"Use the 'Show taskinfo' button to view detailed taskinfo.  ")
                                Else
                                    MsgBox(0+64,"Compare done",$nmbr_changed&" changed file(s) found." _
                                    &@lf&$nmbr_newer&" newer file(s) found." _
                                    &@lf&@lf&"Use the 'Start Update' button to update the destination(s).  " _
                                    &@lf&"Use the 'Show taskinfo' button to view detailed taskinfo.  ")
                                EndIf
                            EndIf
                        EndIf
                    Else
                        if  $compare_stop = 1 Then
                            MsgBox(0+64,"Compare interrupted by user","Interrupted - no differences found until stop")
                        Else
                            MsgBox(0+64,"Compare done","Done - no differences found")
                            if  $log = 2 Then
                                LogEvent(1,$log,"Compare Done - no differences found")  
                            EndIf
                        Endif
                    EndIf
                Else
                    MsgBox(0+48,"","Please select one or more task(s)." _
                            &@lf&@lf&"- Use the Checkboxes.")
                EndIf
        Case $msg = $Button_Update
                if  _checkbox_active($mylist2) = 1 then
                    GUISetCursor(15,1,$myGUI)
                    _update()
                    _setbut()
                    GUISetCursor(2,1,$myGUI)
                Else
                    MsgBox(0+48,"","Please select one or more file(s)to update." _
                            &@lf&@lf&"- Use the Checkboxes.")
                EndIf
        Case $msg = $Button_compare
                _callFapimaster()
        Case $msg = $Button_count
                $compare_stop = 0
                _countMB()
        Case Else
                if  $msg = $GUI_EVENT_PRIMARYUP Then
                    _setbut()
                EndIf
        ;;;
    EndSelect
    If _IsPressed("2E", $dll)and BitAnd(WinGetState("Updater full "&$version, ""), 8) Then; DEL key
        _remove()
    EndIf
    If _IsPressed("2D", $dll)and BitAnd(WinGetState("Updater full "&$version, ""), 8) Then; INS key
        _add_edit()
    EndIf
WEnd
DllClose($dll)
GUIDelete($myGUI)
;
func _start_tasks()
    local $skip = 0
    Global $Fat = 1
    Global $nmbr_newer = 0
    Global $nmbr_changed = 0
    LogEvent(1,$log,"Compare launched -----------------------------------------------------------------------------------------------------------")
    _GUICtrlListViewDeleteAllItems ($mylist2)
    GUISetCursor(15,1,$myGUI)
    for $i = 0 to _GUICtrlListViewGetItemCount ($mylist)-1 step 1
        if $compare_stop = 1 then exitloop
        $skip = 0
        if  BitAND(GUICtrlRead($menu_prec_1), $GUI_CHECKED) then
            $Fat = 0
        Else
            $Fat = 1
        EndIf
        if  _GUICtrlListViewGetCheckedState($mylist,$i) = 1 Then
            _GUICtrlListViewSetItemSelState($mylist,$i)
            _GUICtrlListViewEnsureVisible($mylist,$i,TRUE)
            if  DriveGetFileSystem( StringLeft(_GUICtrlListViewGetItemText($mylist,$i,2),3 )) = "FAT" _
                or DriveGetFileSystem( StringLeft(_GUICtrlListViewGetItemText($mylist,$i,3),3 )) = "FAT" then 
                $Fat = 1
            EndIf
            if  DriveStatus( StringLeft(_GUICtrlListViewGetItemText($mylist,$i,2),3 )) <> "READY" Then
                $skip = 1
                if  $backgnd = 0 then
                    MsgBox(4096,"","Skipping task : "&_GUICtrlListViewGetItemText($mylist,$i,1)&" : Source drive not ready",10)
                EndIf
                if  $log > 0 Then
                    LogEvent(1,$log,"Skipping task : "&_GUICtrlListViewGetItemText($mylist,$i,1) _
                            &" : Source drive : "&StringLeft(_GUICtrlListViewGetItemText($mylist,$i,2),3)&" not ready")
                EndIf
            EndIf
            if  DriveStatus( StringLeft(_GUICtrlListViewGetItemText($mylist,$i,3),3 )) <> "READY" Then
                $skip = 1
                if  $backgnd = 0 then
                    MsgBox(4096,"","Skipping task : "&_GUICtrlListViewGetItemText($mylist,$i,1)&" : Destination drive not ready",10)
                EndIf
                if  $log > 0 Then
                    LogEvent(1,$log,"Skipping task : "&_GUICtrlListViewGetItemText($mylist,$i,1) _
                            &" : Destination drive : "&StringLeft(_GUICtrlListViewGetItemText($mylist,$i,3),3)&" not ready")
                EndIf
            EndIf
            ; just to be sure that source <> destination 
            if  _GUICtrlListViewGetItemText($mylist,$i,2) = _GUICtrlListViewGetItemText($mylist,$i,3) Then
                $skip = 1
                if  $backgnd = 0 then
                    MsgBox(4096,"","Skipping task : "&_GUICtrlListViewGetItemText($mylist,$i,1)&" : Source and destination are the same !",10)
                EndIf
                if  $log > 0 Then
                    LogEvent(1,$log,"Skipping task : "&_GUICtrlListViewGetItemText($mylist,$i,1)&" : Source and destination are the same !")
                EndIf
            EndIf   
            if  $skip = 0 then
                _some_globals_reset()
                ProgressCopy(_GUICtrlListViewGetItemText($mylist,$i,2), _GUICtrlListViewGetItemText($mylist,$i,3),_GUICtrlListViewGetItemText($mylist,$i,1))
                $Last_update = @MDAY&"/"&@MON&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC
                _GUICtrlListViewSetItemText ($mylist,$i,4,$Last_update)
                _iniwrite()
            EndIf
            _GUICtrlListViewSetItemSelState($mylist,$i,0)
        EndIf
    Next
    GUISetCursor(2,1,$myGUI)
EndFunc  ;==>_start_tasks
;
func _some_globals_reset()
    $overallpercent = 0
    $Run1 = 0
    $tosearch = ""
    $OverallQty = 0
    $Overall = 0
    $source = ""
    $overallpercent = 0
    $Progress0Text = ""
    $Progress1Text = ""
    $Progress2Text = ""
EndFunc
;
func _add_edit()
    if  $add = 1 then
        _GUICtrlListViewSetItemSelState($mylist,-1,0)
    EndIf
    _addTask()
    _iniwrite()
    _setbut()
EndFunc  ;==>_add_edit()
;
func _remove()
    if  _GUICtrlListViewGetSelectedCount ($mylist) > 0 then
        if  MsgBox(1+32+256,"Remove Tasks(s)","Do you really want to remove the selected Task(s) from the list ?") = 1 then
            _GUICtrlListViewDeleteItemsSelected($mylist)
            _renumber()
            _iniwrite()
            _setbut()
        Else
            _GUICtrlListViewSetItemSelState($mylist,-1,0)
        EndIf
    Else
        MsgBox(0+48,"","Please select one or more Task(s)")
    EndIf
EndFunc  ;==>_remove
;
Func _upmove()
    if  _GUICtrlListViewGetSelectedCount ($mylist) = 1 and _GUICtrlListViewGetSelectedIndices ($mylist) <> 0  then
        $curindex = _GUICtrlListViewGetSelectedIndices ($mylist)
        $col0 = _GUICtrlListViewGetCheckedState($mylist,$curindex-1)
        $col1 = _GUICtrlListViewGetItemText ($mylist,$curindex-1,1)
        $col2 = _GUICtrlListViewGetItemText ($mylist,$curindex-1,2)
        $col3 = _GUICtrlListViewGetItemText ($mylist,$curindex-1,3)
        $col4 = _GUICtrlListViewGetItemText ($mylist,$curindex-1,4)
        _GUICtrlListViewSetCheckState ($mylist,$curindex-1,_GUICtrlListViewGetCheckedState($mylist,$curindex+0))
        _GUICtrlListViewSetItemText ($mylist,$curindex-1,1,_GUICtrlListViewGetItemText ($mylist,$curindex+0,1))
        _GUICtrlListViewSetItemText ($mylist,$curindex-1,2,_GUICtrlListViewGetItemText ($mylist,$curindex+0,2))
        _GUICtrlListViewSetItemText ($mylist,$curindex-1,3,_GUICtrlListViewGetItemText ($mylist,$curindex+0,3))
        _GUICtrlListViewSetItemText ($mylist,$curindex-1,4,_GUICtrlListViewGetItemText ($mylist,$curindex+0,4))
        ;
        _GUICtrlListViewSetCheckState($mylist,$curindex-0,$col0)
        _GUICtrlListViewSetItemText ($mylist,$curindex-0,1,$col1)
        _GUICtrlListViewSetItemText ($mylist,$curindex-0,2,$col2)
        _GUICtrlListViewSetItemText ($mylist,$curindex-0,3,$col3)
        _GUICtrlListViewSetItemText ($mylist,$curindex-0,4,$col4)
        ;
        _GUICtrlListViewSetItemSelState ($mylist,$curindex-1,1)
        _GUICtrlListViewSetItemSelState ($mylist,$curindex-0,0)
    EndIf
EndFunc  ;==>_upmove
;
Func _downmove()
    if  _GUICtrlListViewGetSelectedCount ($mylist) = 1 and _GUICtrlListViewGetSelectedIndices ($mylist) <> _GUICtrlListViewGetItemCount($mylist)-1 then
        $curindex = _GUICtrlListViewGetSelectedIndices ($mylist)
        $col0 = _GUICtrlListViewGetCheckedState($mylist,$curindex+1)
        $col1 = _GUICtrlListViewGetItemText ($mylist,$curindex+1,1)
        $col2 = _GUICtrlListViewGetItemText ($mylist,$curindex+1,2)
        $col3 = _GUICtrlListViewGetItemText ($mylist,$curindex+1,3)
        $col4 = _GUICtrlListViewGetItemText ($mylist,$curindex+1,4)
        _GUICtrlListViewSetCheckState ($mylist,$curindex+1,_GUICtrlListViewGetCheckedState($mylist,$curindex+0))
        _GUICtrlListViewSetItemText ($mylist,$curindex+1,1,_GUICtrlListViewGetItemText ($mylist,$curindex+0,1))
        _GUICtrlListViewSetItemText ($mylist,$curindex+1,2,_GUICtrlListViewGetItemText ($mylist,$curindex+0,2))
        _GUICtrlListViewSetItemText ($mylist,$curindex+1,3,_GUICtrlListViewGetItemText ($mylist,$curindex+0,3))
        _GUICtrlListViewSetItemText ($mylist,$curindex+1,4,_GUICtrlListViewGetItemText ($mylist,$curindex+0,4))
        ;
        _GUICtrlListViewSetCheckState($mylist,$curindex-0,$col0)
        _GUICtrlListViewSetItemText ($mylist,$curindex-0,1,$col1)
        _GUICtrlListViewSetItemText ($mylist,$curindex-0,2,$col2)
        _GUICtrlListViewSetItemText ($mylist,$curindex-0,3,$col3)
        _GUICtrlListViewSetItemText ($mylist,$curindex-0,4,$col4)
        ;
        _GUICtrlListViewSetItemSelState ($mylist,$curindex+1,1)
        _GUICtrlListViewSetItemSelState ($mylist,$curindex-0,0)
    EndIf
EndFunc  ;==>_downmove
;
func _iniwrite()
    local $nmbrini = 0
    local $nmbrlist = _GUICtrlListViewGetItemCount ($mylist)-1 
    Do
       $inisource = IniRead ($applpath&"Updater.ini", "TASKS", "Task_source" & $nmbrini, "STOP")
       $nmbrini = $nmbrini + 1
    Until $inisource = "STOP" or $inisource = "" 
    ;
    for $i = 0 to $nmbrlist step 1
        if  $backgnd = 0 then
            if  _GUICtrlListViewGetCheckedState($mylist,$i) = 1 then
                IniWrite($applpath&"Updater.ini","TASKS","active"&$i,"1")
            Else
                IniWrite($applpath&"Updater.ini","TASKS","active"&$i,"0")
            EndIf
        EndIf
        if  _GUICtrlListViewGetItemText($mylist,$i,1) <> "" then
            IniWrite($applpath&"Updater.ini","TASKS","Task_name"&$i,_GUICtrlListViewGetItemText($mylist,$i,1))
        Else
            IniWrite($applpath&"Updater.ini","TASKS","Task_name"&$i,"")
        EndIf
        if  _GUICtrlListViewGetItemText($mylist,$i,2) <> "" then
            IniWrite($applpath&"Updater.ini","TASKS","Task_source"&$i,_GUICtrlListViewGetItemText($mylist,$i,2))
        Else
            IniWrite($applpath&"Updater.ini","TASKS","Task_source"&$i,"STOP")
        EndIf
        if  _GUICtrlListViewGetItemText($mylist,$i,3) <> "" then
            IniWrite($applpath&"Updater.ini","TASKS","Task_destination"&$i,_GUICtrlListViewGetItemText($mylist,$i,3))
        Else
            IniWrite($applpath&"Updater.ini","TASKS","Task_destination"&$i,"STOP")
        EndIf
        if  _GUICtrlListViewGetItemText($mylist,$i,4) <> "" then
            IniWrite($applpath&"Updater.ini","TASKS","Last_update"&$i,_GUICtrlListViewGetItemText($mylist,$i,4))
        Else
            IniWrite($applpath&"Updater.ini","TASKS","Last_update"&$i,"-")
        EndIf
    Next
    if  $nmbrini-1 > $nmbrlist+1 then
        for $i = $nmbrlist+1 to $nmbrini-1 step 1
            Inidelete ($applpath&"Updater.ini", "TASKS", "active" & $i)
            Inidelete ($applpath&"Updater.ini", "TASKS", "Task_name" & $i)
            Inidelete ($applpath&"Updater.ini", "TASKS", "Task_source" & $i)
            Inidelete ($applpath&"Updater.ini", "TASKS", "Task_destination" & $i)
            Inidelete ($applpath&"Updater.ini", "TASKS", "Last_update" & $i)
        next 
    EndIf
    sleep(50)
EndFunc  ;==>_iniwrite
;
func _setbut()
    $get_itemcount = _GUICtrlListViewGetItemCount ($mylist)
    select
        Case $get_itemcount < 1
            GUICtrlSetState($Button_check1,$GUI_DISABLE)
            GUICtrlSetState($Button_uncheck1,$GUI_DISABLE)
            GUICtrlSetState($menu_remove,$GUI_DISABLE)
            GUICtrlSetState($menu_edit,$GUI_DISABLE)
            GUICtrlSetState($Button_launch,$GUI_DISABLE)
        Case $get_itemcount = 1
            GUICtrlSetState($Button_check1,$GUI_ENABLE)
            GUICtrlSetState($Button_uncheck1,$GUI_ENABLE)
            GUICtrlSetState($menu_remove,$GUI_ENABLE)
            GUICtrlSetState($menu_edit,$GUI_ENABLE)
            GUICtrlSetState($Button_launch,$GUI_ENABLE)
        Case $get_itemcount > 1
            GUICtrlSetState($Button_check1,$GUI_ENABLE)
            GUICtrlSetState($Button_uncheck1,$GUI_ENABLE)
            GUICtrlSetState($menu_remove,$GUI_ENABLE)
            GUICtrlSetState($menu_edit,$GUI_ENABLE)
            GUICtrlSetState($Button_launch,$GUI_ENABLE)
    EndSelect
    $get_itemcount2 = _GUICtrlListViewGetItemCount ($mylist2)
    select
        Case $get_itemcount2 < 1
            GUICtrlSetState($button_count,$GUI_DISABLE)
            GUICtrlSetState($menu_copy_to,$GUI_DISABLE)
            GUICtrlSetState($Button_check2,$GUI_DISABLE)
            GUICtrlSetState($Button_uncheck2,$GUI_DISABLE)
            GUICtrlSetState($Button_compare,$GUI_DISABLE)
            GUIctrlsetState($Button_Update,$GUI_DISABLE)
        Case $get_itemcount2 = 1
            GUICtrlSetState($Button_check2,$GUI_ENABLE)
            GUICtrlSetState($Button_uncheck2,$GUI_ENABLE)
            GUICtrlSetState($Button_compare,$GUI_ENABLE)
            if  _checkbox_active($mylist2) = 1 then
                GUIctrlsetState($Button_Update,$GUI_ENABLE + $GUI_FOCUS + $GUI_DEFBUTTON)
                GUICtrlSetState($menu_copy_to,$GUI_ENABLE)
                GUICtrlSetState($button_count,$GUI_ENABLE)
            Else
                GUICtrlSetState($button_count,$GUI_DISABLE)
                GUIctrlsetState($Button_Update,$GUI_DISABLE)
                GUICtrlSetState($menu_copy_to,$GUI_DISABLE)
            EndIf
        Case $get_itemcount2 > 1
            GUICtrlSetState($button_count,$GUI_ENABLE)
            GUICtrlSetState($Button_check2,$GUI_ENABLE)
            GUICtrlSetState($Button_uncheck2,$GUI_ENABLE)
            GUICtrlSetState($Button_compare,$GUI_ENABLE)
            if  _checkbox_active($mylist2) = 1 then
                GUIctrlsetState($Button_Update,$GUI_ENABLE + $GUI_FOCUS + $GUI_DEFBUTTON)
                GUICtrlSetState($menu_copy_to,$GUI_ENABLE)
            Else
                GUIctrlsetState($Button_Update,$GUI_DISABLE)
                GUICtrlSetState($menu_copy_to,$GUI_DISABLE)
            EndIf
    EndSelect
EndFunc  ;==>_setbut
;
func _checkbox_active($list)
    for $i = 0 to _GUICtrlListViewGetItemCount ($list)-1 step 1
        if _GUICtrlListViewGetCheckedState($list,$i) = 1 Then
            return 1
        EndIf
    Next
    return 0
EndFunc  ;==>_checkbox_active
;
func _renumber()
    for $i = 0 to _GUICtrlListViewGetItemCount($mylist)
        _GUICtrlListViewSetItemText ($mylist,$i,0,$i+1)
    Next
EndFunc  ;==>_renumber
;
func _gettime($flname)
    $t = FileGetTime($flname,0,0)
    If  Not @error Then
        return $t[2]&"/"&$t[1]&"/"&$t[0]&" "&$t[3]&":"&$t[4]&":"&$t[5]
    Else
        return ""
    EndIf
Endfunc;==>_gettime
;
func _getfname($longname)
    return stringright($longname,StringInStr(_StringReverse($longname),"\") - 1)
EndFunc;==>_getfname
;
func _check_all($list)
    if  _GUICtrlListViewGetItemCount ($list) > 0 then
        for $i = 0 to _GUICtrlListViewGetItemCount ($list)-1 step 1
            if  _GUICtrlListViewGetCheckedState($list,$i) = 0 then
                _GUICtrlListViewSetCheckState ($list,$i)
            EndIf
        Next
    EndIf
EndFunc ;==> _check_all()
;
func _uncheck_all($list)
    if  _GUICtrlListViewGetItemCount ($list) > 0 then
        for $i = 0 to _GUICtrlListViewGetItemCount ($list)-1 step 1
            if  _GUICtrlListViewGetCheckedState($list,$i) = 1 then
                _GUICtrlListViewSetCheckState ($list,$i,0)
            EndIf
        Next
    EndIf
EndFunc ;==> _uncheck_all()
;
func _update()
    LogEvent(1,$log,"Start Update launched")    
    $totalcount = _GUICtrlListViewGetItemCount ($mylist2)
    $logtotalMB = 0
    $logtotalChanged = 0
    $logtotalNewer = 0
    $loggrandtotalMB = 0
    $loggrandtotalChanged = 0
    $loggrandtotalNewer = 0
    for $i = 0 to $totalcount-1 step 1
        if  _GUICtrlListViewGetCheckedState($mylist2,$i) = 1 then
            if  FileExists(_GUICtrlListViewGetItemText($mylist2,$i,1)) then
                FileSetAttrib(_GUICtrlListViewGetItemText($mylist2,$i,1), "-R")
            EndIf
            _GUICtrlListViewSetItemSelState($mylist2,$i,1)
            _GUICtrlListViewEnsureVisible($mylist2,$i,TRUE)
            if  not FileCopy(_GUICtrlListViewGetItemText($mylist2,$i,0),_GUICtrlListViewGetItemText($mylist2,$i,1),9) Then
                LogEvent(3,$log,"Filecopy error in copying "&_GUICtrlListViewGetItemText($mylist2,$i,0)&" to "&_GUICtrlListViewGetItemText($mylist2,$i,1))              
            Else
                if $log = 2 Then
                    LogEvent(1,$log,_GUICtrlListViewGetItemText($mylist2,$i,0)&" "&_GUICtrlListViewGetItemText($mylist2,$i,2) _
                            &" > "&_GUICtrlListViewGetItemText($mylist2,$i,1)&" "&_GUICtrlListViewGetItemText($mylist2,$i,3) _
                            &" "&_GUICtrlListViewGetItemText($mylist2,$i,4))    
                EndIf
                $logtotalMB = $logtotalMB + (_GUICtrlListViewGetItemText($mylist2,$i,4))
                $loggrandtotalMB = $loggrandtotalMB + (_GUICtrlListViewGetItemText($mylist2,$i,4))
                if  _GUICtrlListViewGetItemText($mylist2,$i,6) = "*" Then
                    $logtotalChanged = $logtotalChanged + 1
                    $loggrandtotalChanged = $loggrandtotalChanged + 1
                EndIf
                if  _GUICtrlListViewGetItemText($mylist2,$i,7) = "*" Then
                    $logtotalNewer = $logtotalNewer + 1
                    $loggrandtotalNewer = $loggrandtotalNewer + 1
                EndIf
                $log_taskname = _GUICtrlListViewGetItemText($mylist2,$i,5)
                if  $log_taskname <> _GUICtrlListViewGetItemText($mylist2,$i+1,5) then
                    LogEvent(1,$log,$log_taskname&" - "&$logtotalChanged&" Changed - "&$logtotalNewer&" Newer = "&$logtotalMB&"MB") 
                    $logtotalMB = 0
                    $logtotalChanged = 0
                    $logtotalNewer = 0                  
                EndIf
            EndIf
            FileSetAttrib(_GUICtrlListViewGetItemText($mylist2,$i,1), "-R")
        EndIf
    Next
    _GUICtrlListViewDeleteItemsSelected ($mylist2)
    LogEvent(1,$log,"Total : "&$loggrandtotalChanged&" Changed - "&$loggrandtotalNewer&" Newer = "&round($loggrandtotalMB,1)&"MB")
EndFunc ;==> _update()
;
func _callFapimaster()
    if _GUICtrlListViewGetSelectedCount ($mylist2) = 1 then
        $index_sel = _GUICtrlListViewGetSelectedIndices($mylist2)
        if _GUICtrlListViewGetItemText($mylist2,$index_sel,3) <> "" then
            $ext = StringLower(StringRight(_GUICtrlListViewGetItemText($mylist2,$index_sel,0),3))
            if  $ext = "fmb"or $ext = "rdf" or $ext = "mmb" or $ext = "pll" Then
                $old = _GUICtrlListViewGetItemText($mylist2,$index_sel,1)
                $new = _GUICtrlListViewGetItemText($mylist2,$index_sel,0)
                if  FileExists("C:\Program Files\ORCL Toolbox\FormsAPI Master V2.0\fapimaster.exe") then
                    RunWait("C:\Program Files\ORCL Toolbox\FormsAPI Master V2.0\fapimaster.exe /COMPARE /MODULE1="&$old&" /MODULE2="&$new, "", @SW_MAXIMIZE)
                Elseif FileExists("C:\Program Files\ORCL Toolbox\FormsAPI Master\fapimaster.exe") then
                    MsgBox(0,"New FormsApi master version","Version 2.0 of FormsApi master is available." _
                             &@lf&"pse contact X1GTT tel 6216")
                    RunWait("C:\Program Files\ORCL Toolbox\FormsAPI Master\fapimaster.exe /COMPARE /MODULE1="&$old&" /MODULE2="&$new, "", @SW_MAXIMIZE)
                Else
                    SplashTextOn("", "Please install FormsAPI master in the default subdirectory", 500, 22, 430 ,310 ,1 ,"system", "", "")  
                    sleep(4000)
                    SplashOff()
                EndIf
            Else
                MsgBox(0,"","wrong filetype")
            EndIf
        Else
            MsgBox(0,"","no destination file")
        EndIf
    EndIf
EndFunc ;==> _callFapimaster()
;
Func ProgressCopy($current, $destination,$task)
    ;MsgBox(0,"ProgressCopy",$current&"   "&$destination&"   "&$task)
    $compare_active = 1
    If  $Run1 = 0 Then
        ;If not FileExists ($Destination) then DirCreate ($Destination)
        $source = $current
        If StringRight($current, 1) = '\' Then $current = StringTrimRight($current, 1)
        $tosearch = $current
        $Overall = DirGetSize($tosearch, 1)
        $OverallQty = $Overall[1]
        ;$Gui = GUICreate("Comparing Files - Please Wait -  press ESC to quit", 420, 100, 430, 728, -1, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
        if  $nogui = 0 and not BitAnd(WinGetState("Updater full "&$version, ""), 16)then
            $Gui = GUICreate("Comparing Files - Please Wait -  press ESC to interrupt the compare action.", 680, 90, -1, -1, -1, $WS_EX_TOOLWINDOW)
            GUISetCursor(15,1,$Gui)
            $Progress0Text = GUICtrlCreateLabel("from "&$current&"  to "& $destination, 10, 5, 660, 20, $SS_LEFTNOWORDWRAP)
            $progressbar1 = GUICtrlCreateProgress(10, 24, 660, 20)
            GUICtrlSetColor(-1, 32250)
            $Progress1Text = GUICtrlCreateLabel("", 10, 48, 660, 20, $SS_LEFTNOWORDWRAP)
            $Progress2Text = GUICtrlCreateLabel("", 10, 68, 660, 20, $SS_LEFTNOWORDWRAP)
            GUISetState(@SW_SHOW)
            GUICtrlSetData($Progress1Text, "Working Directory " & $tosearch)
        EndIf
        $Run1 = 1
    EndIf
    Local $search = FileFindFirstFile($current & "\*.*")
    While 1
        if  $compare_stop = 1 then
            $compare_active = 0
            ExitLoop 
        EndIf
        Dim $file = FileFindNextFile($search)
        If @error Or StringLen($file) < 1 Then ExitLoop
        $srcfile = $current &"\"& $file
        ;$trgfile = $destination & StringTrimLeft($current, StringLen($source)) & "\" & $file
        $trgfile = $destination & StringTrimLeft($current, StringLen($tosearch)) & "\" & $file
        ;msgbox (0,"",$srcfile&"     "&$trgfile)
        If  Not StringInStr(FileGetAttrib($srcfile), "D") And ($file <> "." Or $file <> "..") Then
            $OverallQty -= 1
            $overallpercent = 100 - (($OverallQty / $Overall[1]) * 100)
            ;if $nogui = 0 then
            GUICtrlSetData($progressbar1, $overallpercent)
            ;EndIf
            $sourcetime = FileGetTime($srcfile,0,1)
            $destinationtime = FileGetTime($trgfile,0,1)
            if  $sourcetime  > $destinationtime then
                if  $Fat = 1 Then
                    $YYYYMMDDHH_source = StringTrimRight($sourcetime,4)
                    $YYYYMMDDHH_dest = StringTrimRight($destinationtime,4)
                    $MM_source = StringTrimRight(StringTrimLeft($sourcetime,10),2)
                    $MM_dest = StringTrimRight(StringTrimLeft($destinationtime,10),2)
                    $SS_source = StringTrimLeft($sourcetime,12)
                    $SS_dest = StringTrimLeft($destinationtime,12)
                    if  not($YYYYMMDDHH_source = $YYYYMMDDHH_dest _
                        and abs((($MM_source * 60) + $SS_source) - (($MM_dest * 60) + $SS_dest)) < 3 )   then
                        if  $destinationtime = "" then
                            $nmbr_newer = $nmbr_newer + 1
                            $isnew = "*"
                            $ischanged = " "
                        else
                            $nmbr_changed = $nmbr_changed + 1
                            $isnew = " "
                            $ischanged = "*"
                        EndIf
                        _writenewline($mylist2,$srcfile,$trgfile,$Progress2Text,$task,$ischanged,$isnew)
                    EndIf   
                Else
                    if  $destinationtime = "" then
                        $nmbr_newer = $nmbr_newer + 1
                        $isnew = "*"
                        $ischanged = " "
                    else
                        $nmbr_changed = $nmbr_changed + 1
                        $isnew = " "
                        $ischanged = "*"
                    EndIf
                    _writenewline($mylist2,$srcfile,$trgfile,$Progress2Text,$task,$ischanged,$isnew)
                Endif
            Else
                ;if not FileExists($trgfile) then
                ;_writenewline($mylist2,$srcfile,$trgfile,$Progress2Text,$task)
                ;$nmbr_newer = $nmbr_newer + 1
                ;EndIf
                if  $sourcetime < $destinationtime then
                    ;To Ignore the FAT/NTFS timestamp issues of "2 second difference"
                    if  $Fat = 1 then
                        $YYYYMMDDHH_source = StringTrimRight($sourcetime,4)
                        $YYYYMMDDHH_dest = StringTrimRight($destinationtime,4)
                        $MM_source = StringTrimRight(StringTrimLeft($sourcetime,10),2)
                        $MM_dest = StringTrimRight(StringTrimLeft($destinationtime,10),2)
                        $SS_source = StringTrimLeft($sourcetime,12)
                        $SS_dest = StringTrimLeft($destinationtime,12)
                        if  not($YYYYMMDDHH_source = $YYYYMMDDHH_dest _
                            and abs((($MM_source * 60) + $SS_source) - (($MM_dest * 60) + $SS_dest)) < 3 )   then
                            if $backgnd = 0 then
                                if  MsgBox(1+32+256,"CONFIRM","The source file is older than the destination file." _
                                    &@CRLF _
                                    &@CRLF&$srcfile&"  "&_gettime($srcfile) _
                                    &@CRLF&$trgfile&"  "&_gettime($trgfile) _
                                    &@CRLF _
                                    &@CRLF&"add it to the copy list anyway ?") = 1 then
                                    $nmbr_changed = $nmbr_changed + 1
                                    $isnew = " "
                                    $ischanged = "*"
                                    _writenewline($mylist2,$srcfile,$trgfile,$Progress2Text,$task,$ischanged,$isnew)
                                EndIf
                            Else
                                if  $log > 0 Then
                                    LogEvent(1,$log,"source file older than the destination file - NOT copied ! : " _
                                            &$srcfile&"  "&_gettime($srcfile)&" older than "&$trgfile&"  "&_gettime($trgfile))
                                EndIf
                            EndIf
                        EndIf
                    Else
                        if $backgnd = 0 then                        
                            if  MsgBox(1+32+256,"CONFIRM","The source file is older than the destination file." _
                                &@CRLF _
                                &@CRLF&$srcfile&"  "&_gettime($srcfile) _
                                &@CRLF&$trgfile&"  "&_gettime($trgfile) _
                                &@CRLF _
                                &@CRLF&"add it to the copy list anyway ?") = 1 then
                                $nmbr_changed = $nmbr_changed + 1
                                $isnew = " "
                                $ischanged = "*"
                                _writenewline($mylist2,$srcfile,$trgfile,$Progress2Text,$task,$ischanged,$isnew)
                            EndIf
                        Else
                            if  $log > 0 Then
                                LogEvent(1,$log,"source file older than the destination file - NOT copied !" _
                                        &$srcfile&"  "&_gettime($srcfile)&" older than "&$trgfile&"  "&_gettime($trgfile))
                            EndIf
                        EndIf
                    EndIf
                EndIf
            EndIf
        EndIf
        If  StringInStr(FileGetAttrib($srcfile), "D") And ($file <> "." Or $file <> "..") Then
            ;DirCreate($trgfile)
            ;FileSetAttrib($trgfile, "-R")
            ;if     $nogui = 0 and not BitAnd(WinGetState("Updater full "&$version, ""), 16) then
            GUICtrlSetData($Progress1Text, $srcfile)
            ;EndIf
            ProgressCopy($srcfile, $destination,$task)
        EndIf
    WEnd
    FileClose($search)
    If  $overallpercent = 100 or $compare_stop = 1 Then
        if  $nogui = 0 and not BitAnd(WinGetState("Updater full "&$version, ""), 16) then
            GUIDelete($Gui)
        EndIf
        $compare_active = 0
        $Run1 = 0
    EndIf
EndFunc  ;==>ProgressCopy
 ;
Func _writenewline($list,$sfile,$tfile,$progresstext,$tasknm,$changed,$newer)
    $lastindex = _GUICtrlListViewInsertItem ($list, -1,$sfile&"|"&$tfile&"|"&_gettime($sfile)&"|"&_gettime($tfile) _
                 &"|"&_sizediff($sfile,$tfile)&"|"&$tasknm&"|"&$changed&"|"&$newer)
    _GUICtrlListViewSetCheckState ($list,$lastindex)
    GUICtrlSetData($progresstext,$sfile)
    _GUICtrlListViewEnsureVisible($list,$lastindex,TRUE)
EndFunc  ;==>_writenewline
;
Func _sizediff($sfile,$tfile)
    $ssize = FileGetSize ($sfile)/1048576
    $tsize = FileGetSize ($tfile)/1048576
    $diff = round($ssize,2) - round($tsize,2)
    $diff = Round($diff, 1)
    Select
        case $diff = 0
            return ""
        case $diff > 0
            return "+"&$diff 
        case Else
            return $diff
    EndSelect
EndFunc ; ==>_sizediff
;
func _change_default_source_dest_dir()
    ;$popup = GUICreate("Change the default source/destination dir ", 943, 222,166,435, $WS_DLGFRAME, $WS_EX_TOPMOST)
    $popup = GUICreate("Change the default source/destination dir ", 943, 222,-1,-1,-1)
    $Graphic2 = GUICtrlCreateGraphic(40, 20, 860, 120)
    GUICtrlSetBkColor($Graphic2, 0xDDDBCC)
    GuiCtrlSetState($Graphic2,$GUI_DISABLE)
    GUICtrlCreateLabel("Default source dir : ",94,38,170,25)
    GUICtrlSetBkColor(-1, 0xDDDBCC)
    $sourcedir = GUICtrlCreateLabel ("",240,38,600,20)
    GUICtrlSetData($sourcedir,$initsrc)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlCreateLabel("Default destination dir : ",94,88,170,25)
    GUICtrlSetBkColor(-1, 0xDDDBCC)
    $destdir = GUICtrlCreateLabel ("",240,88, 600, 20)
    GUICtrlSetData($destdir,$initdest)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    $Button_setsource = GUICtrlCreateButton("Set",50, 38, 35, 20)
    $Button_setdest = GUICtrlCreateButton("Set",50, 88, 35, 20)
    $Button_ok = GUICtrlCreateButton("Ok", 365, 153, 80, 25)
    $Button_stop = GUICtrlCreateButton("Cancel", 495, 153, 80, 25)
    GUISetState()
    While 1
         $msg2 = GUIGetMsg()
         Select
                Case $msg2 = $Button_setsource
                      $initsrc = FileSelectFolder("Choose a default source folder or drive.","")
                      if not @error and $initsrc <> "" then
                          GUICtrlSetData($sourcedir,$initsrc)
                      EndIf
                Case $msg2 = $Button_setdest
                      $initdest = FileSelectFolder("Choose a default destination folder or drive.","")
                      if not @error and $initdest <> "" then
                          GUICtrlSetData($destdir,$initdest)
                          IniWrite ($applpath&"Updater.ini", "DEFAULT_DIRS", "Initdest",$initdest)
                      EndIf
                Case $msg2 = $Button_ok
                      if $initsrc <> Iniread($applpath&"Updater.ini", "DEFAULT_DIRS", "Initsrc","") Then
                          IniWrite ($applpath&"Updater.ini", "DEFAULT_DIRS", "Initsrc",$initsrc)
                      EndIf
                      if $initdest <> Iniread($applpath&"Updater.ini", "DEFAULT_DIRS", "Initdest","") Then
                          IniWrite ($applpath&"Updater.ini", "DEFAULT_DIRS", "Initdest",$initdest)
                      EndIf
                      ExitLoop
                Case $msg2 = $Button_stop
                      ExitLoop
                Case Else
         EndSelect
    WEnd
    ;_GUICtrlListViewEnsureVisible ($mylist,0,TRUE)
    GUIDelete($popup)
endfunc ;==>_change_default_source_dest_dir()
;
func _addTask()
    if  _GUICtrlListViewGetSelectedCount ($mylist) = 1 or $add = 1 Then
        Local $selindex,$taskname,$source,$destination,$labelsource,$labeldestination,$index
        if $add = 0 then
           $selindex = _GUICtrlListViewGetSelectedIndices ($mylist)
           $taskname = _GUICtrlListViewGetItemText($mylist,$selindex,1)
           $labelsource =_GUICtrlListViewGetItemText($mylist,$selindex,2)
           $labeldestination =_GUICtrlListViewGetItemText($mylist,$selindex,3)
        Else
            _GUICtrlListViewEnsureVisible ($mylist,_GUICtrlListViewGetItemCount($mylist)-1,TRUE)
            $taskname = "Task "&(_GUICtrlListViewGetItemCount($mylist)+1)
        EndIf
        ;$popup = GUICreate("Add/Edit a Task", 570,230,-1,-1, $WS_DLGFRAME, $WS_EX_TOPMOST)
        $popup = GUICreate("Add/Edit a Task", 585,235,-1,-1,-1)
        $Graphic2 = GUICtrlCreateGraphic(19, 80, 540, 80)
        GUICtrlSetBkColor($Graphic2, 0xDDDBCC)
        GuiCtrlSetState($Graphic2,$GUI_DISABLE)
        $Group2 = GUICtrlCreateGroup("", 19, 73, 540, 86, $BS_FLAT)
        GUICtrlCreateLabel("Task name : ",137,16,95,25)
        $new_task_name = GUICtrlCreateInput ( $taskname, 220, 15, 150, 20)
        GUIctrlsetState($new_task_name,$GUI_FOCUS)
        $Chkbox_ea = GuiCtrlCreateCheckbox(" Edit and Add", 220, 50, 170, 20)
        if $add = 1 Then
           GUIctrlsetState($Chkbox_ea,$GUI_DISABLE)
        Else
           GUIctrlsetState($Chkbox_ea,$GUI_ENABLE)
        EndIf
        $but_source = GUICtrlCreateButton("Source", 60, 91, 80, 22) 
        GUICtrlSetTip($but_source, "Choose a source folder.")
        $but_flip = GUICtrlCreateButton("Flip", 485, 102, 30, 38,$BS_ICON) 
        GUICtrlSetImage (-1, $applpath&"flip.ico")
        GUICtrlSetTip($but_flip, "Swap the source and destination")
        $slabel = GUICtrlCreateLabel($labelsource,150,91,330,25,$SS_SUNKEN )
        ;GUICtrlSetBkColor(-1, 0xDDDBCC)
        $but_destination = GUICtrlCreateButton("Destination", 60, 123, 80, 22) 
        GUICtrlSetTip($but_destination, "Choose a destination folder.")
        $dlabel = GUICtrlCreateLabel($labeldestination,150,123,330,25,$SS_SUNKEN)
        ;GUICtrlSetBkColor(-1, 0xDDDBCC)
        $Button_ok = GUICtrlCreateButton("Ok", 185, 190, 80, 25)
        $Button_stop = GUICtrlCreateButton("Cancel", 315, 190, 80, 25)
        GUISetState()
        While 1
              $msg2 = GUIGetMsg()
                Select
                    Case $msg2 = $but_source
                            if GUICtrlRead($slabel) <> "" then
                               $source = FileSelectFolder("Choose a source folder.",StringLeft(GUICtrlRead($slabel),3),0,GUICtrlRead($slabel))
                            else
                               $source = FileSelectFolder("Choose a source folder.",$initsrc)
                            EndIf
                            if not @error and $source <> "" then
                               GUICtrlSetData($slabel,$source)
                            EndIf
                    Case $msg2 = $but_destination
                            if GUICtrlRead($dlabel) <> "" then
                               $destination = FileSelectFolder("Choose a destination folder.",StringLeft(GUICtrlRead($dlabel),3),1,GUICtrlRead($dlabel))
                            else
                               $destination = FileSelectFolder("Choose a destination folder.",$initdest,1)
                           EndIf
                            if not @error and $destination <> "" then
                               GUICtrlSetData($dlabel,$destination)
                            EndIf
                    Case $msg2 = $but_flip
                            $tempsource = GUICtrlRead($slabel)
                            GUICtrlSetData($slabel,GUICtrlRead($dlabel))
                            GUICtrlSetData($dlabel,$tempsource)
                    Case $msg2 = $Button_ok
                            if _check_existtaskname(GUICtrlRead($new_task_name)) = 0 _ 
                                or (GUICtrlRead($new_task_name) = $taskname and GUICtrlRead($Chkbox_ea) <> 1) then
                                if GUICtrlRead($new_task_name) <> "" then
                                    if GUICtrlRead($slabel) <> "" and GUICtrlRead($dlabel) <> "" then
                                        if  GUICtrlRead($slabel) <> GUICtrlRead($dlabel)  then 
                                            if $add = 1 or GUICtrlRead($Chkbox_ea) = 1  then
                                                $index = _GUICtrlListViewInsertItem ($mylist, -1, "|"&GUICtrlRead($new_task_name)&"|"&GUICtrlRead($slabel)&"|"&GUICtrlRead($dlabel)&"|"&"-")
                                                _GUICtrlListViewSetItemText ($mylist,$index,0,$index+1)
                                                _GUICtrlListViewSetCheckState ($mylist,$index)
                                                _GUICtrlListViewEnsureVisible($mylist,$index,TRUE)
                                            Else
                                                _GUICtrlListViewSetItemText ($mylist,$selindex,1,GUICtrlRead($new_task_name))
                                                _GUICtrlListViewSetItemText ($mylist,$selindex,2,GUICtrlRead($slabel))
                                                _GUICtrlListViewSetItemText ($mylist,$selindex,3,GUICtrlRead($dlabel))
                                            EndIf
                                            ExitLoop
                                        Else
                                            MsgBox(0+48,"Add/Edit","Source folder and Destination folder must be different.")  
                                        EndIf
                                    Else
                                        MsgBox(0+48,"Add/Edit","Missing input, try again")  
                                    EndIf
                                Else
                                    MsgBox(0+48,"Add/Edit","Missing Taskname.") 
                                EndIf
                            Else
                                MsgBox(0+48,"Add/Edit","This Taskname already exist.") 
                            EndIf
                    Case $msg2 = $Button_stop
                            ExitLoop
                    Case Else
                EndSelect
        WEnd
        ;_GUICtrlListViewEnsureVisible ($mylist,0,TRUE)
        GUIDelete($popup)
    Else
        MsgBox(0+48,"","Please select one Task")
    EndIf
endfunc ;==>_addTask()
;
Func  _copy_to()
    local $initcopyto = Iniread($applpath&"Updater.ini", "DEFAULT_DIRS", "Initcopyto","")
    if  _GUICtrlListViewGetItemCount ($mylist2) > 0 and _checkbox_active($mylist2) = 1 Then
        if  _GUICtrlListViewGetSelectedCount ($mylist) = 1 then
            $popup = GUICreate("Copy source file(s) to a destination (website upload subdir)", 500,160,-1,-1,-1)
            GUICtrlCreateLabel("Copy all the selected source file(s) from one selected Task to this destination : " _
                                &@lf&"- the directory structure will also be copied.",20,12,470,35)
            $but_source = GUICtrlCreateButton("Destination", 35, 65, 80, 22) 
            $cptolabel = GUICtrlCreateLabel($initcopyto,125,65,330,25,$SS_SUNKEN )
            $Button_ok = GUICtrlCreateButton("Ok", 140, 113, 80, 25)
            $Button_stop = GUICtrlCreateButton("Cancel", 270, 113, 80, 25)
            GUISetState()
            While 1
                  $msg3 = GUIGetMsg()
                    Select
                        Case $msg3 = $but_source
                                if GUICtrlRead($cptolabel) <> "" then
                                   $copyto = FileSelectFolder("Choose a destination folder.",StringLeft(GUICtrlRead($cptolabel),3),1,GUICtrlRead($cptolabel))
                                else
                                   $copyto = FileSelectFolder("Choose a destination folder.",$initcopyto,1)
                                EndIf
                                if not @error and $copyto <> "" then
                                   GUICtrlSetData($cptolabel,$copyto)
                                EndIf
                        Case $msg3 = $Button_ok
                                IniWrite ($applpath&"Updater.ini", "DEFAULT_DIRS", "Initcopyto",GUICtrlRead($cptolabel))
                                if GUICtrlRead($cptolabel) <> "" then
                                    $cpopath = GUICtrlRead($cptolabel)
                                    GUIDelete($popup)
                                    _source_copy_to($cpopath)
                                EndIf
                                ExitLoop
                        Case $msg3 = $Button_stop
                                ExitLoop
                        Case Else
                    EndSelect
            WEnd
            GUIDelete($popup)
        Else
            MsgBox(0+48,"","Please select one Task")
        EndIf
    Else
        MsgBox(0+48,"","No source file(s) selected")
    EndIf
EndFunc ;=>_copy_to()
;
Func _source_copy_to($path)
    local $dest
    $selindex = _GUICtrlListViewGetSelectedIndices ($mylist)
    $totalcount = _GUICtrlListViewGetItemCount ($mylist2)
    for $i = 0 to $totalcount-1 step 1
         ;must be checked and taskname mylist2 must be the same as the selected taskname in mylist
         if _GUICtrlListViewGetCheckedState($mylist2,$i) = 1 _
            and _GUICtrlListViewGetItemText($mylist,$selindex,1) = _GUICtrlListViewGetItemText($mylist2,$i,5) then
             _GUICtrlListViewEnsureVisible($mylist2,$i,TRUE)
             ;MsgBox(0,"",_GUICtrlListViewGetItemText($mylist2,$i,1)&"  -   "&_GUICtrlListViewGetItemText($mylist,$selindex,3)&"   -   "&$path)
             $dest = StringReplace(_GUICtrlListViewGetItemText($mylist2,$i,1),_GUICtrlListViewGetItemText($mylist,$selindex,3),$path)
             if @extended = 1 then
                _GUICtrlListViewSetItemSelState($mylist2,$i,1)
                if  FileExists($dest) then
                    FileSetAttrib($dest, "-R")
                EndIf
               ;MsgBox(0,"",_GUICtrlListViewGetItemText($mylist2,$i,0)&"  -   "&$dest)
                if not FileCopy(_GUICtrlListViewGetItemText($mylist2,$i,0),$dest,9) then
                    LogEvent(3,$log,"Copy source files to... error in copying "&_GUICtrlListViewGetItemText($mylist2,$i,0)&" to "&$dest)    
                EndIf
                FileSetAttrib($dest, "-R")
                if $log = 2 Then
                    LogEvent(1,$log,_GUICtrlListViewGetItemText($mylist2,$i,0)&" "&_GUICtrlListViewGetItemText($mylist2,$i,2)&" > "&$dest)  
                EndIf
                ;_GUICtrlListViewSetItemSelState($mylist2,$i,0)
             endif
         EndIf
    Next
    MsgBox(0+64,"Copy source file(s)","Done")
EndFunc ;==> _source_copy_to($path)
;
Func _check_existtaskname($taskname)
    $totaltasks = _GUICtrlListViewGetItemCount ($mylist)    
    for $i = 0 to $totaltasks-1 step 1
        if _GUICtrlListViewGetItemText($mylist,$i,1) = $taskname Then
           return 1
        EndIf
    Next
    return 0
EndFunc ;==> _check_existtaskname
;
Func  _countMB()
    ;local $initcopyto = Iniread($applpath&"Updater.ini", "DEFAULT_DIRS", "Initcopyto","")
    if  _GUICtrlListViewGetItemCount ($mylist2) > 0 and _checkbox_active($mylist2) = 1 Then
        if  $compare_stop = 1 Then
            MsgBox(0,"Compare interrupted","Compare interrupted by user")
        EndIf
        $popup = GUICreate("Detailed taskinfo", 770,330,-1,-1,-1,$WS_EX_TOPMOST)
        $mylist3 = GUICtrlCreateListView("Taskname|# Files changed|# Newer files|Total +/- MB|Free space GB|Destination drive", 17, 17, 735, 210, _
        BitOR($LVS_SHOWSELALWAYS,$LVS_NOSORTHEADER, $LVS_REPORT), _
        BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT, $LVS_EX_FLATSB ))
        _GUICtrlListViewSetColumnWidth($mylist3,0,160)
        _GUICtrlListViewSetColumnWidth($mylist3,1,120)
        _GUICtrlListViewSetColumnWidth($mylist3,2,100)
        _GUICtrlListViewSetColumnWidth($mylist3,3,100)
        _GUICtrlListViewSetColumnWidth($mylist3,4,110)
        _GUICtrlListViewSetColumnWidth($mylist3,5,123)
        GuiCtrlCreateLabel("Total :", 25, 230, 70, 20)
        GUICtrlSetFont (-1,10,800,1,"tahoma")
        $grndttl_Changed = GuiCtrlCreateLabel(0, 185, 230, 100, 20)
        GUICtrlSetFont (-1,10,800,1,"tahoma")
        $grndttl_Newer = GuiCtrlCreateLabel(0, 305, 230, 90, 20)
        GUICtrlSetFont (-1,10,800,1,"tahoma")
        $grndttl_MB = GuiCtrlCreateLabel(0, 405, 230, 90, 20)
        GUICtrlSetFont (-1,10,800,1,"tahoma")
        GUICtrlCreateLabel("Use the 'Start Update' button to start updating the destination(s).",205,265,380,25)
        $Button_ok = GUICtrlCreateButton("Ok", 345, 290, 80, 25)
        GUISetState()
        $totalfiles = _GUICtrlListViewGetItemCount ($mylist2) 
        $totalMB = 0
        $totalChanged = 0
        $totalNewer = 0
        $grandtotalMB = 0
        $grandtotalChanged = 0
        $grandtotalNewer = 0
        GUISetCursor(15,1,$popup)
        SplashTextOn("","Retrieving info ...", 370, 22, -1 ,-1,1 ,"system", "", "")
        for $i = 0 to $totalfiles-1 step 1
            ;$task = _GUICtrlListViewGetItemText($mylist2,$i,5)
            if  _GUICtrlListViewGetCheckedState($mylist2,$i) = 1 Then
                $totalMB = $totalMB + (_GUICtrlListViewGetItemText($mylist2,$i,4))
                $grandtotalMB = $grandtotalMB + (_GUICtrlListViewGetItemText($mylist2,$i,4))
                if  _GUICtrlListViewGetItemText($mylist2,$i,6) = "*" Then
                    $totalChanged = $totalChanged + 1
                    $grandtotalChanged = $grandtotalChanged + 1
                EndIf
                if  _GUICtrlListViewGetItemText($mylist2,$i,7) = "*" Then
                    $totalNewer = $totalNewer + 1
                    $grandtotalNewer = $grandtotalNewer + 1
                EndIf
            ;EndIf
                $task = _GUICtrlListViewGetItemText($mylist2,$i,5)
                if  $task <> _GUICtrlListViewGetItemText($mylist2,$i+1,5) then
                    $drive = StringLeft(_GUICtrlListViewGetItemText($mylist2,$i,1),3)
                    $free = Round(DriveSpaceFree ( $drive )/1000,2)
                    $lastindex = _GUICtrlListViewInsertItem ($mylist3,-1,$task&"|"&$totalChanged&"|"&$totalNewer _
                                                            &"|"&round($totalMB,1)&"|"&$free&"|"&$drive)
                    $totalMB = 0
                    $totalChanged = 0
                    $totalNewer = 0
                EndIf
            EndIf
        next
        ;$lastindex = _GUICtrlListViewInsertItem ($mylist3,-1," "&"|"&$grandtotalChanged&"|"&$grandtotalNewer _
        ;                                       &"|"&round($grandtotalMB,1)&"|"&" "&"|"&" ")
        GUICtrlSetData($grndttl_Changed,$grandtotalChanged)
        GUICtrlSetData($grndttl_Newer,$grandtotalNewer)
        GUICtrlSetData($grndttl_MB,round($grandtotalMB,1)&" MB")
        splashOff()
        GUISetCursor(2,1,$popup)
        While 1
            $msg4 = GUIGetMsg()
            Select
                Case $msg4 = $Button_ok
                    ExitLoop
                Case Else
            EndSelect
        WEnd
        GUIDelete($popup)
    Else
        MsgBox(0+48,"","No source file(s) selected")
    EndIf
EndFunc ;=>_copy_to()
;
Func _fill_paramlist()
    ;MsgBox(0,"total parameters",$CmdLine[0])
    for $i = 1 to $CmdLine[0]-1 step 1
        $param[$i] = $CmdLine[$i+1]
        if  not Number($param[$i]) Then
            return 0
        EndIf
    next
    return 1
EndFunc
;
func _check_task_in_para($upd)
    for $i = 1 to $CmdLine[0]-1 step 1
        ;MsgBox(0,"",$param[$i]&"  "&$upd&"   "&$CmdLine[0]-1)
        if  $param[$i] = $upd Then
            return 1
        EndIf
    next
    return 0    
EndFunc
;
Func _log_parameters()
    if  $backgnd = 1 and $CmdLine[0] > 1 and $log > 0 Then
        $tekst = "Parameters :"
        for $i = 1 to $CmdLine[0] step 1
            $tekst = $tekst&" "&$CmdLine[$i]
        Next
        LogEvent(1,$log,$tekst) 
    EndIf
EndFunc
;
Func LogEvent($EventType,$log_type,$String)
Select
    Case $log_type == 0
        Return
    Case $EventType == 1
    $EventName = " [I] >"
    Case $EventType == 2
    $EventName = " [W] >"
    Case $EventType == 3
    $EventName = " [E] >"
EndSelect
   $LogFile = FileOpen ($applpath&@ComputerName&"_update_log.txt", 1)
    If $LogFile = -1 Then
        Return
    EndIf
    FileWriteLine ($LogFile, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & ";" &$EventName & ";" & $String)
    FileClose ($LogFile)
EndFunc

The attachment includes :

updater_full.exe

updater_full.au3

up.ico

down.ico

flip.ico

updater_full_readme.txt

Please enjoy.

Any suggestions are welcome.

Updaterv2.0.zip

Edited by Gyzmok
D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper
Link to comment
Share on other sites

@Krol & @jaenster : tnx :whistle:

@jaenster : I understand your concern but that's not my style.

D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper
Link to comment
Share on other sites

I did a backup script with AutoIT a while back...mine is triggered when new MSC (mass storage class) connections are made and uses a date stored in a INI to determine what to backup.

I really need to make a GUI front-end to the thing as it works really great for backing up to flash drives.

Anywho: homepage for that project is here: http://www.shrum.net/code/copy2msc

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

  • 1 month later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...