#cs ----------------------------------------------------------------------------
App: LogFlush
By: David Orlo
www.DavidOrlo.com
Artistic License 2.0
http://www.perlfoundation.org/artistic_license_2_0
Creative Commons License
Attribution Non-Commercial Share Alike (cc by-nc-sa)
http://creativecommons.org/licenses/by-nc-sa/3.0/
#ce ----------------------------------------------------------------------------
#include <StringSize.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <FontConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <Date.au3>
#include <Math.au3>
Global $AppName = "LogFlush"
Global $AppVersion = "2.8"
Global $machinename = @ComputerName
Global $time = @HOUR & ":" & @MIN & ":" & @SEC
Global $date = @YEAR & "/" & @MON & "/" & @MDAY
Global Const $AC_SRC_ALPHA = 1
Dim $title[20] = ["Log Flush", _ ;Borrowed this cool little idea from UEZ (Thanks Man You Rock)
"Version " & $AppVersion, _
"Flush Your Log Files", _
"Recursive Folder Scaning", _
"Log Aging", _
"Need Help?", _
"View the ReadME File", _
"Log Flush", _
"By: David Orlo", _
"www.DavidOrlo.com", _
"Programmed In", _
"100% Pure AutoIT", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯"]
Global $c = 0 ;counter for sleep
Global $i = 1 ;for character
Global $j = 0 ;for array
Global $k = UBound($title) - 1
Global $s = 150 ;sleep time
Global $in = True
Global $effect = Random(1, 2, 1)
Global $igui
Global $lfgui
Global $guiimg
Global $time = @HOUR & ":" & @MIN & ":" & @SEC
Global $date = @YEAR & "/" & @MON & "/" & @MDAY
Global $inifile = "includes\LogFlush.ini"
If FileExists("includes\LogFlush.ini") = 0 Then
createini()
EndIf
$RAppVersion = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "AppVersion")
If $RAppVersion <> $AppVersion Then
createini()
EndIf
Global $startlocation = IniRead($inifile,"Options","Startlocation","C:\inetpub")
Global $filetype = IniRead($inifile,"Options","filetype",".log")
Global $recursion = IniRead($inifile,"Options","recursion",5)
Global $ignorefolders = IniRead($inifile,"Options","ignorefolders","NONE")
Global $usefolders = IniRead($inifile,"Options","usefolders","*")
Global $aging = IniRead($inifile,"Options","aging",15)
_GDIPlus_Startup()
introgui()
Sleep(5000)
maingui()
While 1
$Msg = GUIGetMsg()
Display_Info()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Browse
$var = FileSelectFolder("Choose a folder.", "")
GUICtrlSetData($InputLoc, $var)
Case $Save
writeini()
$winpos = WinGetPos("","Start Log Location")
SplashTextOn("LogFlush", "Configuration Saved", 250, 55, $winpos[0] +10, $winpos[1] +180, 1, "", 18)
Sleep(1500)
SplashOff()
Case $Flush
writeini()
runflush()
EndSwitch
WEnd
Func introgui()
$igui = GUICreate("", 265, 330, -1, -1, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_LAYERED + $WS_EX_TOOLWINDOW)
$guiimg = _GDIPlus_ImageLoadFromFile("includes\LogFlush.png")
SETBITMAP($igui, $guiimg, 255)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $igui, "int", 500, "long", 262160)
GUISetState(@SW_SHOW, $igui)
EndFunc ;==>introgui
Func maingui()
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $igui, "int", 1000, "long", 0x00090000)
$lfgui = GUICreate("Log Flush", 266, 379, -1, -1)
GUISetBkColor(0x3c3c3c)
GUICtrlCreatePic("includes\LFHeader.jpg", 0, 0, 265, 39, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
$Group1 = GUICtrlCreateGroup("Start Log Location", 5, 42, 255, 80, BitOR($BS_CENTER, $BS_FLAT))
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group1), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
Global $InputLoc = GUICtrlCreateInput($startlocation, 10, 61, 245, 21)
Global $Browse = GUICtrlCreateButton("Browse", 180, 88, 75, 25, $WS_GROUP)
GUICtrlSetBkColor(-1, 0x07d9ff)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("File Types", 5, 124, 255, 50)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group2), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
Global $InputType = GUICtrlCreateInput($filetype, 10, 143, 245, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Use Folders", 5, 178, 255, 46)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group4), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
Global $InputUse = GUICtrlCreateInput($usefolders, 10, 194, 245, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group5 = GUICtrlCreateGroup("Ignore Folders", 5, 230, 255, 46)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group5), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
Global $InputIgnore = GUICtrlCreateInput($ignorefolders, 10, 248, 245, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Recursion", 5, 279, 125, 48)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group3), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
Global $InputRecursion = GUICtrlCreateCombo("", 15, 298, 105, 25)
GUICtrlSetData(-1, "6|5|4|3|2|1", $recursion)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group6 = GUICtrlCreateGroup("Aging", 135, 279, 125, 48)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group6), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
Global $InputAging = GUICtrlCreateInput($aging, 143, 298, 105, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Save = GUICtrlCreateButton("Save", 5, 329, 65, 44, $WS_GROUP)
GUICtrlSetBkColor(-1, 0x068dff)
Global $Flush = GUICtrlCreateButton("FLUSH 'EM", 74, 330, 186, 44, $WS_GROUP)
GUICtrlSetState(-1, $GUI_FOCUS)
GUICtrlSetBkColor(-1, 0x068dff)
GUISetState(@SW_SHOW, $lfgui)
EndFunc ;==>maingui
Func Display_Info()
Sleep(10)
If $in Then
If $i <> StringLen($title[$j]) + 1 Then
If $effect = 1 Then
WinSetTitle($lfgui, "", StringLeft($title[$j], $i)) ;effect 1a, 1 by 1
Else
WinSetTitle($lfgui, "", StringRight($title[$j], $i)) ;effect 2a, scroll to right
EndIf
$i += 1
Else
If $c = $s Then
$i = 1
$in = False
$c = 0
$effect = Random(1, 2, 1)
Else
$c += 1
EndIf
EndIf
Else
If $i <> StringLen($title[$j]) + 1 Then
If $effect = 1 Then
WinSetTitle($lfgui, "", StringLeft($title[$j], StringLen($title[$j]) - $i)) ;effect 1b, 1 by 1
Else
WinSetTitle($lfgui, "", StringRight($title[$j], StringLen($title[$j]) - $i)) ;effect 2b, scroll to left
EndIf
$i += 1
Else
$i = 1
$in = True
$effect = Random(1, 2, 1)
If $j = $k Then
$j = 0
Else
$j += 1
EndIf
EndIf
EndIf
EndFunc ;==>Display_Info
Func writeini()
If RegRead("HKEY_LOCAL_MACHINE\Software\IT3\IT-Tech-Tools","IT Tech Tools") = "" Then
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3", "IT-Tech-Tools", "REG_SZ", "IT Tech Tools")
EndIf
If RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush","LF") = "" Then
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush", "LF", "REG_SZ", "Log Flush")
EndIf
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "startlocation", "REG_SZ", GUICtrlRead($InputLoc))
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "filetype", "REG_SZ", GUICtrlRead($InputType))
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "recursion", "REG_SZ", GUICtrlRead($InputRecursion))
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "ignorefolders", "REG_SZ", GUICtrlRead($InputIgnore))
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "usefolders", "REG_SZ", GUICtrlRead($InputUse))
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "aging", "REG_SZ", GUICtrlRead($InputAging))
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "appversion", "REG_SZ", $AppVersion)
$inifile = "includes\LogFlush.ini"
IniWrite($inifile, "options", "startlocation", GUICtrlRead($InputLoc))
IniWrite($inifile, "options", "filetype", GUICtrlRead($InputType))
IniWrite($inifile, "options", "recursion", GUICtrlRead($InputRecursion))
IniWrite($inifile, "options", "ignorefolders", GUICtrlRead($InputIgnore))
IniWrite($inifile, "options", "usefolders", GUICtrlRead($InputUse))
IniWrite($inifile, "options", "aging", GUICtrlRead($InputAging))
EndFunc
Func runflush()
$winpos = WinGetPos("","Start Log Location")
SplashTextOn("LogFlush", "Running", 250, 55, $winpos[0] +10, $winpos[1] +180, 1, "", 18)
writeini()
RunWait("LFTask.exe")
$tfoldercount = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats","Folders Processed TD")
$tfilecount = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats","Files Processed TD")
$foldercount = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Folders Processed")
$filecount = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Files Processed")
$skippedfolder = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Folders Skipped")
$skippedfiletotal = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Files Skipped")
$skippedfileage = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Skipped Aging")
$skippedfileext = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Skipped Extension")
SplashOff()
MsgBox(0, "Log Flush Report", "Machine Name: " & $machinename & @CRLF & _
"Folders Processed Total: " & $foldercount & @CRLF & _
"Files Processed Total: " & $filecount & @CRLF & _
"Folders Skipped Total: " & $skippedfolder & @CRLF & _
"Files Skipped Total: " & $skippedfiletotal & @CRLF & _
"Skipped due to Aging: " & $skippedfileage & @CRLF & _
"Skipped due to Extension: " & $skippedfileext & @CRLF & _
"----------------------------" & @CRLF & _
"Folders Processed Lifetime: " & $tfoldercount & @CRLF & _
"Files Processed Lifetime: " & $tfilecount)
EndFunc
Func createini()
$ANLEN = StringLen ($AppName)
$eo = _MathCheckDiv ($ANLEN,2)
$starcount = (22 - $ANLEN) / 2
$starcount = Round($starcount, 0)
If $eo = 1 Then
$starcount = $starcount -1
EndIf
If $starcount = 11 Then
$star = "***********"
ElseIf $starcount = 10 Then
$star = "**********"
ElseIf $starcount = 9 Then
$star = "*********"
ElseIf $starcount = 8 Then
$star = "********"
ElseIf $starcount = 7 Then
$star = "*******"
ElseIf $starcount = 6 Then
$star = "******"
ElseIf $starcount = 5 Then
$star = "*****"
ElseIf $starcount = 4 Then
$star = "****"
ElseIf $starcount = 3 Then
$star = "***"
ElseIf $starcount = 2 Then
$star = "**"
ElseIf $starcount = 1 Then
$star = "*"
Else
$star = ""
EndIf
$file = FileOpen($inifile, 2)
FileWrite($file, "¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸" & @CRLF)
FileWrite($file, $star & " " & $AppName & " " & $AppVersion & " by: David Orlo " & $star & @CRLF)
FileWrite($file, "************ www.DavidOrlo.com ************" & @CRLF)
FileWrite($file, "******* Creative Commons (BY-NC-SA) *******" & @CRLF)
FileWrite($file, "-- Please Read the ReadME File for HELP --" & @CRLF)
FileWrite($file, "¸.•*\_/*•*\_/*•.¸ .. ¥ .. ¸.•*\_/*•*\_/*•.¸" & @CRLF)
FileWrite($file, "" & @CRLF)
FileWrite($file, "[Options]" & @CRLF)
FileWrite($file, "startlocation=C:\inetpub" & @CRLF)
FileWrite($file, "filetype=.log" & @CRLF)
FileWrite($file, "recursion=5" & @CRLF)
FileWrite($file, "ignorefolders=NONE" & @CRLF)
FileWrite($file, "usefolders=*" & @CRLF)
FileWrite($file, "aging=15" & @CRLF)
FileClose($file)
EndFunc
Func _GUICtrlCreateGroup($sText, $iLeft, $iTop, $iWidth, $iHeight, $bColor = 0x000000)
Local $aLabel[6] = [5]
Local $aStringSize = _StringSize($sText)
$aLabel[1] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + 1, 1, $iHeight) ; Left Line.
$aLabel[2] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + 1, 10, 1) ; Top Left Line.
GUICtrlCreateLabel(" " & $sText, $iLeft + 7, $iTop - 6, $aStringSize[2] - 3, 15)
$aLabel[3] = GUICtrlCreateLabel("", $iLeft + $aStringSize[2] + 4, $iTop + 1, $iWidth - $aStringSize[2] - 3, 1) ; Top Right Line.
$aLabel[4] = GUICtrlCreateLabel("", $iLeft + $iWidth + 1, $iTop + 1, 1, $iHeight) ; Right Line.
$aLabel[5] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + $iHeight + 1, $iWidth + 1, 1) ; Bottom Line.
For $i = 1 To $aLabel[0]
GUICtrlSetBkColor($aLabel[$i], $bColor)
Next
EndFunc ;==>_GUICtrlCreateGroup
Func WM_HSCROLL($HWND, $IMSG, $IWPARAM, $ILPARAM)
SETBITMAP($igui, $guiimg, 255)
EndFunc ;==>WM_HSCROLL
Func WM_NCHITTEST($HWND, $IMSG, $IWPARAM, $ILPARAM)
If ($HWND = $igui) And ($IMSG = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST
Func SETBITMAP($HGUI, $guiimg, $IOPACITY)
Local $HSCRDC, $HMEMDC, $HBITMAP, $HOLD, $PSIZE, $TSIZE, $PSOURCE, $TSOURCE, $PBLEND, $TBLEND
$HSCRDC = _WinAPI_GetDC(0)
$HMEMDC = _WinAPI_CreateCompatibleDC($HSCRDC)
$HBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($guiimg)
$HOLD = _WinAPI_SelectObject($HMEMDC, $HBITMAP)
$TSIZE = DllStructCreate($TAGSIZE)
$PSIZE = DllStructGetPtr($TSIZE)
DllStructSetData($TSIZE, "X", _GDIPlus_ImageGetWidth($guiimg))
DllStructSetData($TSIZE, "Y", _GDIPlus_ImageGetHeight($guiimg))
$TSOURCE = DllStructCreate($TAGPOINT)
$PSOURCE = DllStructGetPtr($TSOURCE)
$TBLEND = DllStructCreate($TAGBLENDFUNCTION)
$PBLEND = DllStructGetPtr($TBLEND)
DllStructSetData($TBLEND, "Alpha", $IOPACITY)
DllStructSetData($TBLEND, "Format", $AC_SRC_ALPHA)
_WinAPI_UpdateLayeredWindow($HGUI, $HSCRDC, 0, $PSIZE, $HMEMDC, $PSOURCE, 0, $PBLEND, $ULW_ALPHA)
_WinAPI_ReleaseDC(0, $HSCRDC)
_WinAPI_SelectObject($HMEMDC, $HOLD)
_WinAPI_DeleteObject($HBITMAP)
_WinAPI_DeleteDC($HMEMDC)
EndFunc ;==>SETBITMAP