#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=icons\shell32_dll_Ico899_ico_Ico1.ico #AutoIt3Wrapper_outfile=renamer.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ================================================================================================================ ; LANGUAGE OPTIONS Opt("TrayMenuMode",1) AutoItSetOption("MustDeclareVars", 0) ; ================================================================================================================ ; INCLUDES (update as needed) #Include #include #Include #include #include #include #include ; ================================================================================================================ ; DUPLICATE INSTANCE CHECK (may need to remove or move this around depending on where it is needed) If UBound(ProcessList(@ScriptName)) > 2 Then Exit ; ================================================================================================================ ; SCRIPT IDENTITY (this is based on the filename of the script/executable) $sAppName = "Renamer" $sAppAuthor = "Sean Shrum" $sAppVersion = "2.03" $sAppEmail = StringLower($sAppName)& "@shrum.net" $sAppHome = "http://www.shrum.net/sean/code/" & StringLower($sAppName) $sAppNews = $sAppHome & "/updates.html" $sAppSupport = $sAppHome & "/support.html" $sAppFileType ="." & StringLower($sAppName) $aAppBuild = FileGetTime(@ScriptFullPath) $sAppBuild = $aAppBuild[0] & "." & $aAppBuild[1] & "." & $aAppBuild[2] & " @ " & $aAppBuild[3] & ":" & $aAppBuild[4] & ":" & $aAppBuild[5] $sAppTitle = $sAppName & " v." & $sAppVersion $sAppSettings = "HKCU\software\shrum.net\" & $sAppName ; ================================================================================================================ ; VARIABLE DECLARATIONS / DEFAULTS Global $bDebug=False, $bVerbose ;;Global $aFiles = _ArrayCreate(0), $sDirectory, $bSubdirectories, $sFind, $sReplace, $bCase, $sTokenString Global $aFiles, $sDirectory, $bSubdirectories, $sFind, $sReplace, $bCase, $sTokenString Global $iEnumerate = "1", $iPadding = "3", $iIncrement = "1", $iSuccess = 0 ; ================================================================================================================ ; TRAY ICON AND TOOLTIP SET (looks for .ico in same folder as .exe otherwise uses the build icon) TraySetToolTip($sAppTitle) TraySetIcon($sAppName & ".ico") ; ================================================================================================================ ; SPLASH SCREEN / TRAYTIP BUBBLE (*only* if no command line params are present: automated run/batch call) if $CmdLine[0] = 0 Then Traytip($sAppTitle,$sAppHome & @CRLF & "By " & $sAppAuthor & " :: " & $sAppEmail,5) ; ================================================================================================================ ; REGISTRY UPDATES (location, version, runcount) $iRunCount = RegRead($sAppSettings, "Executed") RegWrite($sAppSettings, "Executed", "REG_SZ", $iRunCount + 1) RegWrite($sAppSettings, "", "REG_SZ", @Scriptdir) RegWrite($sAppSettings, "Version", "REG_SZ", $sAppVersion) ; ================================================================================================================ ; PROGRAM GROUP / SHORTCUTS CREATION (fires only when Executed reg value = "" from above) If $iRunCount = "" Then DirCreate(@ProgramsCommonDir & "\shrum.net\" & $sAppName) FileCreateShortcut(@ScriptFullPath, @ProgramsCommonDir & "\shrum.net\" & $sAppName & "\" & $sAppName & ".lnk") FileCreateShortcut($sAppHome, @ProgramsCommonDir & "\shrum.net\" & $sAppName & "\Homepage.lnk") FileCreateShortcut($sAppSupport, @ProgramsCommonDir & "\shrum.net\Support.lnk") FileCreateShortcut(@ScriptFullPath, @UserProfileDir & "\application data\microsoft\Internet Explorer\Quick Launch\" & $sAppName & ".lnk") EndIf ; ================================================================================================================ ; SYSTRAY MENU DEFINITIONS (if any) ; N/A ; ================================================================================================================ ; LAST RUN SETTINGS LOAD ; _SettingsLoad() ; ================================================================================================================ ; COMMAND-LINE / .INI EVALUATION if $CmdLine[0] = 0 Then _SettingsLoad() _CommandLineBuilder() else for $i = 1 to $CmdLine[0] $aParam = StringSplit($CmdLine[$i], "=") $sParam = StringUpper(stringleft($aParam[1],1)) Select case $sParam = "D";irectory $sDirectory = $aParam[2] case $sParam = "S";ubdirectories $bSubdirectories = stringupper($aParam[2]) case $sParam = "F";ind $sFind = $aParam[2] case $sParam = "C";ase sensitive $bCase = StringUpper($aParam[2]) case $sParam = "R";eplace $sReplace = $aParam[2] case $sParam = "T";okened string $sTokenString = $aParam[2] case $sParam = "E";numerate start $iEnumerate = $aParam[2] case $sParam = "Z";ero padding $iPadding = $aParam[2] case $sParam = "I";ncrement by $iIncrement = $aParam[2] case $sParam = "?" Run(@ComSpec & " /c start " & $sAppHome) exit EndSelect Next EndIf ; ================================================================================================================ ; ARGUMENT CHECKS / PROMPTS if $bCase = "y" or $bCase = True Then $bCase = True Else $bCase = False endif if $bSubdirectories = "y" or $bSubdirectories = True Then $bSubdirectories = True Else $bSubdirectories = False endif ; ================================================================================================================ ; SETTINGS SAVE (all user passed params should be formatted to program-desired formats by this point) ; _SettingsSave() ; ================================================================================================================ ; HOTKEY DEFINITIONS (if any) ; N/A ; ================================================================================================================ ; DEBUG WINDOW (notepad; if requested) if $bDebug then _DebugSetup() ; ================================================================================================================ ; MAIN PROGRAM TrayTip($sAppTitle,"Files analyzed/renamed :: " & _Rename(), 5,16) sleep(5000) Exit $iSuccess ; FUNCTION LIBRARY ============================================================================================== Func _AboutDialog() _ConsoleWrite("+ _AboutDialog()") msgbox(0,"About", $sAppTitle & " ( build " & $sAppBuild & " ) by " & $sAppAuthor & @crlf & $sAppHome & " :: " & StringLower($sAppName) & "@shrum.net") if msgbox(4,$sAppTitle, "Would you like to visit " & $sAppName & "'s website for information regarding it's usage?") = 6 then _ConsoleWrite(": Opening website '" & $sAppSupport & "'") Run(@ComSpec & " /c start " & $sAppSupport) endif _ConsoleWrite("- _AboutDialog()") EndFunc Func _ArrayMerge (ByRef $aTemp1, $aTemp2, $iBase=1) _Consolewrite("+ _ArrayMerge()") $iTimer = TimerInit() $iRows1 = ubound($aTemp1) - $iBase $iCols1 = ubound($aTemp1,2) $iRows2= ubound($aTemp2) - $iBase $iCols2 = ubound($aTemp2,2) If $iCols1 <> $iCols2 then seterror(1) Exit endif if $iCols1 = 0 Then $iTotal = $aTemp1[0] + $aTemp2[0] redim $aTemp1[$iTotal+1] For $i = $aTemp1[0] + $iBase to $iTotal $aTemp1[$i] = $aTemp2[$i - ($aTemp1[0] + $iBase) + 1] next $aTemp1[0] = $iTotal Else $iTotal = $aTemp1[0][0] + $aTemp2[0][0] redim $aTemp1[$iTotal+1][$iCols1] For $i = $aTemp1[0][0] + $iBase to $iTotal for $j = 0 to ($iCols1 - 1) $aTemp1[$i][$j] = $aTemp2[$i - ($aTemp1[0][0] + $iBase) + 1][$j] Next next $aTemp1[0][0] = $iTotal EndIf _ConsoleWrite(": " & $iTotal & " new entries merged in " & Round(TimerDiff($iTimer)/1000,2) & " secs") _Consolewrite("- _ArrayMerge()") EndFunc Func _CommandLineBuilder() if RegRead("HKCU\software\shrum.net\" & $sAppName, "X") = "" then $iBuilderX = (@DesktopWidth-339)/2 $iBuilderY = (@DesktopHeight-470)/2 Else $iBuilderX = RegRead("HKCU\software\shrum.net\" & $sAppName, "X") $iBuilderY = RegRead("HKCU\software\shrum.net\" & $sAppName, "Y") EndIf GuiCreate($sAppTitle & " - Builder mode",339,430,$iBuilderX, $iBuilderY, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Label_1 = GuiCtrlCreateLabel("[D]irectory to scan:", 10, 10, 320, 20) $oDirectory = GuiCtrlCreateInput($sDirectory, 10, 30, 190, 20) $oBrowse = GuiCtrlCreateButton("...", 210, 30, 20, 20) $oSubdirectories = GuiCtrlCreateCheckbox("[S]ubdirectories", 240, 30, 90, 20) if $bSubdirectories = "Y" then GUICtrlSetState(-1,$GUI_CHECKED) $Label_10 = GuiCtrlCreateLabel("[F]ind text:", 10, 60, 310, 20) $oFind = GuiCtrlCreateInput($sFind, 10, 80, 220, 20) $oCase = GuiCtrlCreateCheckbox("[C]ase sensitive", 240, 80, 90, 20) if $bCase = "Y" then GUICtrlSetState(-1,$GUI_CHECKED) $Label_12 = GuiCtrlCreateLabel("[R]eplacement text (leave blank to remove found text):", 10, 110, 320, 20) $oReplace = GuiCtrlCreateInput($sReplace, 10, 130, 320, 20) $Label_14 = GuiCtrlCreateLabel("[T]oken replacement text:", 10, 160, 320, 20) $oTokenString = GuiCtrlCreateCombo($sTokenString, 10, 180, 320, 21) GUICtrlSetData(-1,"[year][mnum0][mdaynum0]-[enum].[ext]|[yr][mnum0][mdaynum0]_[hour24][min][sec]-[enum].[ext]|[yr].[mnum].[mdaynum].[hour24].[min].[sec]-[enum].[ext]","") $Label_17 = GuiCtrlCreateLabel("[basename], [ext], [enum], [year], [yr], [mnum0], [mnum], [month], [mon], [mdaynum0], [mdaynum], [wdaynum0], [wdaynum], [weekday], [wday], [hour24], [hour0], [hour], [ampm], [min], [sec]", 30, 278, 290, 58) $Group_16 = GuiCtrlCreateGroup(" Tokens ", 10, 260, 320, 80) $Label_20 = GuiCtrlCreateLabel("[E]numerate start", 10, 210, 80, 20) $oEnumerate = GuiCtrlCreateInput($iEnumerate, 10, 230, 80, 20) $Label_21 = GuiCtrlCreateLabel("[Z]ero Padding", 130, 210, 80, 20) $oPadding = GuiCtrlCreateInput($iPadding, 130, 230, 80, 20) $Label_25 = GuiCtrlCreateLabel("[I]ncrement by", 250, 210, 80, 20) $oIncrement = GuiCtrlCreateInput($iIncrement, 250, 230, 80, 20) $oRename = GuiCtrlCreateButton("&Rename", 10, 350, 100, 30) $oShortcut = GuiCtrlCreateButton("Make &shortcut", 120, 350, 100, 30) $oUpdate = GuiCtrlCreateButton("&Update check", 230, 350, 100, 30) $oHomepage = GuiCtrlCreateButton("Home&page", 10, 390, 100, 30) $oSupport = GuiCtrlCreateButton("&Support", 120, 390, 100, 30) $oNews = GuiCtrlCreateButton("&News", 230, 390, 100, 30) GUICtrlSetState($oDirectory, $GUI_FOCUS) GUICtrlSetState($oRename, $GUI_DEFBUTTON) GuiSetState() WinActivate($sAppTitle & " - Builder mode") While 1 $msg = GuiGetMsg() Select case $msg = $oShortcut $sDirectory = GUICtrlRead($oDirectory) $sFind = GUICtrlRead($oFind) $sReplace = GUICtrlRead($oReplace) $sTokenString = GUICtrlRead($oTokenString) if GUICtrlread($oSubdirectories) = 4 Then $bSubdirectories = "" Else $bSubdirectories = "Y" EndIf if GUICtrlread($oCase) = 4 Then $bCase = "" Else $bCase = "Y" EndIf $iEnumerate = GUICtrlRead($oEnumerate) $iPadding = GUICtrlRead($oPadding) $iIncrement = GUICtrlRead($oIncrement) $sCmdLine = 'd="' & $sDirectory & '" s=' & $bSubdirectories & ' f="' & $sFind & '" r="' & $sReplace & '" c=' & $bCase & ' t="' & $sTokenString & '" e=' & $iEnumerate & ' z=' & $iPadding & ' i=' & $iIncrement if $sTokenString <> "" then FileCreateShortcut(@ScriptFullPath, @DesktopDir & "\" & $sAppName & " - '" & $sTokenString & "'.lnk",@ScriptDir,$sCmdLine,$sAppName & " " & $sCmdLine) Else FileCreateShortcut(@ScriptFullPath, @DesktopDir & "\" & $sAppName & " - '" & $sFind & "' to '" & $sReplace & "'.lnk",@ScriptDir,$sCmdLine,$sAppName & " " & $sCmdLine) EndIf msgbox(64,$sAppTitle,"A shortcut has been created on your desktop.",10) case $msg = $oBrowse $sResult = FileSelectFolder("Folder to scan", "", 2, "") If not @error Then GUICtrlSetData($oDirectory, $sResult) GUICtrlSetState($oFind, $GUI_FOCUS) case $msg = $oRename $sDirectory = GUICtrlRead($oDirectory) $sFind = GUICtrlRead($oFind) $sReplace = GUICtrlRead($oReplace) $sTokenString = GUICtrlRead($oTokenString) if GUICtrlread($oSubdirectories) = 4 Then $bSubdirectories = "" Else $bSubdirectories = "Y" EndIf if GUICtrlread($oCase) = 4 Then $bCase = "" Else $bCase = "Y" EndIf $iEnumerate = GUICtrlRead($oEnumerate) $iPadding = GUICtrlRead($oPadding) $iIncrement = GUICtrlRead($oIncrement) trayTip($sAppTitle,"Files analyzed/renamed :: " & _Rename(), 5,16) sleep(5000) _SettingsSave() case $msg = $oHomepage _ShellExecute($sAppHome) case $msg = $oSupport _ShellExecute($sAppSupport) case $msg = $oNews _ShellExecute($sAppNews) case $msg = $oUpdate _UpdateCheck() Case $msg = $GUI_EVENT_CLOSE _CommandLineBuilderRecordPos() Exit EndSelect WEnd GUIDelete() EndFunc func _CommandLineBuilderRecordPos() $aPos = WinGetPos($sAppTitle & " - Builder mode","") RegWrite("HKCU\software\shrum.net\" & $sAppName, "X", "REG_SZ", $aPos[0]) RegWrite("HKCU\software\shrum.net\" & $sAppName, "Y", "REG_SZ", $aPos[1]) EndFunc func _ConsoleWrite($sMsg) _DebugOut($sMsg) Consolewrite($sMsg & @CRLF) EndFunc Func _Exit() _ConsoleWrite("+ _Exit()") _SettingsSave() Exit EndFunc Func _FileSearch($FSstartDir, $FSFilepattern = ".", $FSFolderpattern = ".", $FSFlag = 0, $FSrecurse = True, $FSdepth = 0) If StringRight($FSstartDir, 1) <> "\" Then $FSstartDir &= "\" If $FSdepth = 0 Then $FSfilecount = DirGetSize($FSstartDir, 1) Global $FSarray[$FSfilecount[1] + $FSfilecount[2] + 1] EndIf $FSsearch = FileFindFirstFile($FSstartDir & "*.*") If @error Then Return While 1 $FSnext = FileFindNextFile($FSsearch) If @error Then ExitLoop If StringInStr(FileGetAttrib($FSstartDir & $FSnext), "D") Then If $FSrecurse And StringRegExp($FSnext, $FSFolderpattern, 0) Then _FileSearch($FSstartDir & $FSnext, $FSFilepattern, $FSFolderpattern, $FSFlag, $FSrecurse, $FSdepth + 1) EndIf If $FSFlag <> 1 Then $FSarray[$FSarray[0] + 1] = $FSstartDir & $FSnext $FSarray[0] += 1 EndIf ElseIf StringRegExp($FSnext, $FSFilepattern, 0) And $FSFlag <> 2 Then $FSarray[$FSarray[0] + 1] = $FSstartDir & $FSnext $FSarray[0] += 1 EndIf WEnd FileClose($FSsearch) If $FSdepth = 0 Then ReDim $FSarray[$FSarray[0] + 1] _ArraySort($FSarray) Return $FSarray EndIf EndFunc func _Rename() $iSuccess = 0 $iFailure = 0 if $sDirectory = "" then Msgbox(16,$sAppTitle,"Can't continue until a DIRECTORY has been defined.") return "-/-" elseif $sFind = "" and $sTokenString = "" then Msgbox(16,$sAppTitle,"Can't continue until a FIND string or TOKEN string has been defined.") return "-/-" elseif $sReplace <> "" and $sTokenString <> "" Then Msgbox(16,$sAppTitle,"Can't continue with a REPLACE string and a TOKEN string defined.") return "-/-" elseif $sTokenString <> "" Then if stringinstr($sTokenString, "[enum]") = 0 and stringinstr($sTokenString, "[basename]") = 0 Then Msgbox(16,$sAppTitle,"Can't continue with a TOKEN string rename without [enum] or [basename] tokens. It will generate duplicate names.") return "-/-" EndIf EndIf TrayTip($sAppTitle, "Retrieving filenames...",5,16) if $bSubdirectories = "Y" then $aFiles = _FileSearch($sDirectory, ".", ".", 1) Else $aFiles = _FileSearch($sDirectory, ".", ".", 1, False) EndIf TrayTip($sAppTitle, "Analyzing " & $aFiles[0] & " files...",5,16) for $i = 1 to $aFiles[0] $sPathname = StringLeft($aFiles[$i],StringInStr($aFiles[$i],"\",0,-1)) $sFilename = StringTrimLeft($aFiles[$i],StringInStr($aFiles[$i],"\",0,-1)) if $sTokenString <> "" Then if $bCase = "Y" Then if stringinstr($sFilename,$sFind,1) = 0 Then ContinueLoop Else if stringinstr($sFilename,$sFind,0) = 0 Then ContinueLoop EndIf $sRenamed = $sPathname & _Tokens($iSuccess) $sBasename = StringLeft($sFilename,StringInStr($sFilename,".",0,-1)-1) $sExt = StringTrimLeft($sFilename,StringInStr($sFilename,".",0,-1)) $sRenamed = StringReplace($sRenamed, "[basename]", $sBasename) $sRenamed = StringReplace($sRenamed, "[ext]", $sExt) Else if $bCase = "Y" Then $sRenamed = $sPathname & StringReplace($sFilename, $sFind, $sReplace,0,1) else $sRenamed = $sPathname & StringReplace($sFilename, $sFind, $sReplace) EndIf EndIf if $sFilename <> $sRenamed then $iSuccess = $iSuccess + Filemove($aFiles[$i], $sRenamed) Next return $aFiles[0] & "/" & $iSuccess EndFunc Func _SettingsLoad() _ConsoleWrite("+ _SettingsLoad()") $sDirectory = RegRead("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Directory") $bSubdirectories = RegRead("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Subdirectories") $sFind = RegRead("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Find") $bCase = RegRead("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Case") $sReplace = RegRead("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Replace") $sTokenString = RegRead("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Tokenstring") $iEnumerate = RegRead("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Enumerate") if $iEnumerate = "" then $iEnumerate = 1 $iPadding = RegRead("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Padding") if $iPadding = "" then $iPadding = 3 $iIncrement = RegRead("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Increment") if $iIncrement = "" then $iIncrement = 1 _ConsoleWrite("- _SettingsLoad()") EndFunc Func _SettingsSave() _ConsoleWrite("+ _SettingsSave()") RegWrite("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Directory", "REG_SZ", $sDirectory) RegWrite("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Subdirectories", "REG_SZ", $bSubdirectories) RegWrite("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Find", "REG_SZ", $sFind) RegWrite("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Case", "REG_SZ", $bCase) RegWrite("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Replace", "REG_SZ", $sReplace) RegWrite("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Tokenstring", "REG_SZ", $sTokenString) RegWrite("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Enumerate", "REG_SZ", $iEnumerate) RegWrite("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Padding", "REG_SZ", $iPadding) RegWrite("HKEY_CURRENT_USER\software\shrum.net\" & $sAppName, "Increment", "REG_SZ", $iIncrement) _ConsoleWrite("- _SettingsSave()") EndFunc Func _ShellExecute($sCmd) _ConsoleWrite("+ _ShellExecute()") if $sCmd = "" Then _ConsoleWrite(": No command passed") Else _ConsoleWrite(": Running '" & $sCmd & "'") shellExecute($sCmd) EndIf _ConsoleWrite("- _ShellExecute()") endfunc Func _ShellExecuteWait($sCmd) _ConsoleWrite("+ _ShellExecuteWait()") if $sCmd = "" Then _ConsoleWrite(": No command passed") Else _ConsoleWrite(": Running '" & $sCmd & "'") ShellExecuteWait($sCmd) EndIf _ConsoleWrite("- _ShellExecuteWait()") endfunc Func _Tokens($iNumber) $sYear = @YEAR $sYr = stringtrimleft(@YEAR,2) $sMNum0 = @MON select case $sMNum0 = "01" $sMonth="January" case $sMNum0 = "02" $sMonth="Feburary" case $sMNum0 = "03" $sMonth="March" case $sMNum0 = "04" $sMonth="April" case $sMNum0 = "05" $sMonth="May" case $sMNum0 = "06" $sMonth="June" case $sMNum0 = "07" $sMonth="July" case $sMNum0 = "08" $sMonth="August" case $sMNum0 = "09" $sMonth="September" case $sMNum0 = "10" $sMonth="October" case $sMNum0 = "11" $sMonth="November" case $sMNum0 = "12" $sMonth="December" EndSelect $sMNum = number($sMNum0) $sMon = stringleft($sMonth, 3) $sMDayNum0 = @MDAY $sMDayNum = number(@MDAY) $sWDayNum0 = @WDAY Select case $sWDayNum0 = "01" $sWeekDay = "Sunday" case $sWDayNum0 = "02" $sWeekDay = "Monday" case $sWDayNum0 = "03" $sWeekDay = "Tuesday" case $sWDayNum0 = "04" $sWeekDay = "Wednesday" case $sWDayNum0 = "05" $sWeekDay = "Thursday" case $sWDayNum0 = "06" $sWeekDay = "Friday" case $sWDayNum0 = "07" $sWeekDay = "Saturday" EndSelect $sWDayNum = stringtrimleft($sWDayNum0, 1) $sWDay = StringLeft($sWeekDay,3) $sHour24 = @HOUR $sAMPM = "am" if $sHour24 >= "12" Then $sAMPM = "pm" Select Case $sHour24 = "00" $sHour0 = "12" Case $sHour24 = "01" $sHour0 = "01" Case $sHour24 = "02" $sHour0 = "02" Case $sHour24 = "03" $sHour0 = "03" Case $sHour24 = "04" $sHour0 = "04" Case $sHour24 = "05" $sHour0 = "05" Case $sHour24 = "06" $sHour0 = "06" Case $sHour24 = "07" $sHour0 = "07" Case $sHour24 = "08" $sHour0 = "08" Case $sHour24 = "09" $sHour0 = "09" Case $sHour24 = "10" $sHour0 = "10" Case $sHour24 = "11" $sHour0 = "11" Case $sHour24 = "12" $sHour0 = "12" Case $sHour24 = "13" $sHour0 = "01" Case $sHour24 = "14" $sHour0 = "02" Case $sHour24 = "15" $sHour0 = "03" Case $sHour24 = "16" $sHour0 = "04" Case $sHour24 = "17" $sHour0 = "05" Case $sHour24 = "18" $sHour0 = "06" Case $sHour24 = "19" $sHour0 = "07" Case $sHour24 = "20" $sHour0 = "08" Case $sHour24 = "21" $sHour0 = "09" Case $sHour24 = "22" $sHour0 = "10" Case $sHour24 = "23" $sHour0 = "11" EndSelect $sHour = Number($sHour0) $sMinute = @MIN $sSecond = @SEC $sString = $sTokenString $sString = StringReplace($sString, "[year]", $sYear) $sString = StringReplace($sString, "[yr]", $sYr) $sString = StringReplace($sString, "[mnum0]", $sMNum0) $sString = StringReplace($sString, "[mnum]", $sMNum) $sString = StringReplace($sString, "[month]", $sMonth) $sString = StringReplace($sString, "[mon]", $sMon) $sString = StringReplace($sString, "[mdaynum0]", $sMDayNum0) $sString = StringReplace($sString, "[mdaynum]", $sMDayNum) $sString = StringReplace($sString, "[wdaynum0]", $sWDayNum0) $sString = StringReplace($sString, "[wdaynum]", $sWDayNum) $sString = StringReplace($sString, "[weekday]", $sWeekDay) $sString = StringReplace($sString, "[wday]", $sWDay) $sString = StringReplace($sString, "[hour24]", $sHour24) $sString = StringReplace($sString, "[hour0]", $sHour0) $sString = StringReplace($sString, "[hour]", $sHour) $sString = StringReplace($sString, "[ampm]", $sAMPM) $sString = StringReplace($sString, "[min]", $sMinute) $sString = StringReplace($sString, "[sec]", $sSecond) $sString = StringReplace($sString, "[enum]", stringformat("%0" & $iPadding & "d", $iEnumerate + ($iNumber * $iIncrement))) return $sString EndFunc func _UpdateCheck() _ConsoleWrite("+ _UpdateCheck()") $sTemp = "" $aTemp = stringsplit(_InetGetSource($sAppHome & "/" & stringlower($sAppName) & ".au3"), @CRLF) For $i = 1 to $aTemp[0] if StringInStr($aTemp[$i], "$sAppVersion") then $sTemp = $aTemp[$i] ExitLoop endif Next if $sTemp <> "" then $aOnlineVersion = StringSplit($sTemp, "=") $sOnlineVersion = StringReplace(StringStripWS($aOnlineVersion[2], 8), '"', "") _ConsoleWrite(": Online = " & $sOnlineVersion) _ConsoleWrite(": User = " & $sAppVersion) if $sOnlineVersion <> "" and Not Stringinstr($sOnlineVersion, "") Then If $sAppVersion < $sOnlineVersion Then _ConsoleWrite(": User is OLDER") TrayTip($sAppTitle, "Your version is out-of-date",5) $sMsg = "A newer version of this program is available for download." & @CRLF & @CRLF $sMsg &= "Do you want to visit the " & $sAppname & " site to download the newer version?" & @CRLF & @CRLF $sMsg &= "Selecting 'Yes' will close this app and take you to the website." If MsgBox(4, $sAppTitle, $sMsg) = 6 Then _ConsoleWrite(": Launching default web browser to " & $sAppHome) _ShellExecute($sAppHome) Exit EndIf ElseIf $sAppVersion >= $sOnlineVersion Then _ConsoleWrite(": User is UP-TO-DATE") TrayTip($sAppTitle, "Your version is up-to-date.",5) EndIf Else _ConsoleWrite(": Data received but no version info found") traytip($sAppTitle,"Unable to locate versioning info in data received." & @CRLF & "Please go to the homepage for further update details.",5) EndIf Else _ConsoleWrite(": Unable to obtain version content") traytip($sAppTitle,"Unable to obtain online version info." & @CRLF & "Check your connection and try again.",5) EndIf _ConsoleWrite("- _UpdateCheck()") EndFunc