#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=CopyThumbs.ico #AutoIt3Wrapper_outfile=G:\CopyThumbs.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <file.au3> #Include <AssocArrays.au3> #Include <UnixTime.au3> Opt("TrayMenuMode",2) TraySetToolTip("XBMC Thumbnail Copier") AutoItSetOption("TrayAutoPause", 0) AutoItSetOption("TrayOnEventMode", 1) ;--- Tray Menu ---; $SyncNow = TrayCreateItem("Sync now!") TrayItemSetOnEvent($SyncNow, "SyncNow") ;--- Settings ---; Global $settingsGeneral Global $clients Global $pcStates AssocArrayCreate($settingsGeneral, 3) AssocArrayCreate($clients, 1, 1) AssocArrayCreate($pcStates, 1, 1) $iniGeneral = IniReadSection(@AutoItExe & ".settings.ini", "general") $iniClients = IniReadSection(@AutoItExe & ".settings.ini", "clients") $iniPcStates = IniReadSection(@AutoItExe & ".pcstates.ini", "pcstates") For $i = 1 To $iniGeneral[0][0] AssocArrayAssign($settingsGeneral, $iniGeneral[$i][0], $iniGeneral[$i][1]) Next For $i = 1 To $iniClients[0][0] AssocArrayAssign($clients, $iniClients[$i][0], $iniClients[$i][1]) Next If $iniPcStates <> 1 Then For $i = 1 To $iniPcStates[0][0] AssocArrayAssign($pcStates, $iniPcStates[$i][0], $iniPcStates[$i][1]) Next EndIf ;--- Globals ---; Global $SyncToyFilePath = AssocArrayGet($settingsGeneral, "SyncToyFilePath") Global $Interval = AssocArrayGet($settingsGeneral, "Interval") ;in minutes, 5 hours Global $TimeOut = AssocArrayGet($settingsGeneral, "TimeOut") Global $LogLevel = AssocArrayGet($settingsGeneral, "LogLevel") LogEntry('Variables initialized, LogLevel set to: "' & $LogLevel & '"') While True For $i = 1 to (UBound($iniClients, 1) - 1) Step +1 $lastRun = IniRead(@AutoItExe & ".pcstates.ini", "pcstates", "client" & $i, 0) If $lastRun == 0 Or $lastRun + ($Interval * 60) <= _TimeGetStamp() Then Log("Client" & $i & " Timer passed (" & $Interval & " minutes, or first run)") RunSchedule($i) Else LogEntry("Client" & $i & " timer not yet expired (" & Round((($lastRun + ($Interval * 60)) - _TimeGetStamp()) /60, 2) & " minutes remaining)", "Debug") EndIf Next Sleep($TimeOut * 60000) WEnd Func RunSchedule($clientIndex) If Ping(AssocArrayGet($clients, "client" & $clientIndex)) <> 0 Then RunWait(StringReplace($SyncToyFilePath, "{0}", $clientIndex)) IniWrite(@AutoItExe & ".pcstates.ini", "pcstates", "client" & $clientIndex, _TimeGetStamp()) LogEntry("Client" & $clientIndex & " Script last executed") Else LogEntry("Client" & $clientIndex & " Source is not accessible", "Debug") EndIf EndFunc Func SyncNow() For $i = 1 to (UBound($iniClients, 1) - 1) Step +1 LogEntry("Client" & $i & " forced run via Sync now") RunSchedule($i) Next EndFunc Func LogEntry($logEntry, $entryLogLevel = "Normal") Switch $entryLogLevel Case "Normal" _FileWriteLog(@AutoItExe & ".log", $logEntry) Case "Debug" If $LogLevel == "Debug" Then _FileWriteLog(@AutoItExe & ".log", $logEntry) EndIf Case "Off" Case Else MsgBox(48, "Not supported exception", 'LogLevel "' & $LogLevel & '" is not supported, choose from "Debug", "Normal" or "Off"') Exit EndSwitch EndFunc
While True If WinActive("Parcelware 2.3.0.42", "Polling-overzicht") = 0 Then ExitLoop EndIf WinWait("Selectie label", "", 2) If(WinActivate("Selectie label") <> 0) Then Send("{ENTER}") EndIf WinWait("Het bestand opslaan als", "", 2) if(WinActivate("Het bestand opslaan als") <> 0) Then Send($count) $count = $count + 1 Send("{ENTER}") EndIf WEnd