Jump to content

Utilities collection


snowman533
 Share

Recommended Posts

this neat program has 4 inbuilt programs, this is the list as it appears

-V2 players, you will know what i am on about here (Aranock, Thule, Mercadia, etc) a random number generator for death rulettes, this may just be your ticket to a winning day

-File Maker, premake any file of your choosing, much easier than using notepad to premake your files for use

-Error Recorder, record an error from any error window, just type in the title of that window, then you can post it to a support forum for that program to find out what caused that error, note that any successful recording will have OK at the start of the file when you open it

-Empty directory remover, thanks to KaFu for the code, allows you to remove those annoying empty directories

special features:

-file maker, error recorder and directory remover feature a find directory function for saving of the results files or setting the start directory of the empty directory remover

-empty directory remover makes a results file of all directories removed to the desktop, so you know exactly what directories are being removed

-if you choose your main drive as the start directory for the directory remover, it will search that entire drive for empty directories, only takes 1 minute to 5 minutes depending how many directories/folders you have

-features a credits window when "Exit" is pressed

please if i have missed anyone for thanking to help make this, let me know

and after some deep consideration, i realized that theres nothing wrong with posting the code, so here it is ^_^

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <File.au3>
#include <array.au3>

$gui=GUICreate("Utilities Collection")
GUISetState(@SW_SHOW, $gui)
$Button1=GUICtrlCreateButton("Exit", 346, 5, 50, 25)
$Button2=GUICtrlCreateButton("Random number", 5, 5, 100, 25)
GUICtrlCreateLabel("creates a random number between and including 1 and 5500" & @lf & "for Death Rulettes in the V2 clone", 5, 30)
$Button3=GUICtrlCreateButton("File Maker", 5, 70, 100, 25)
GUICtrlCreateLabel("Creates a file with any extension, perfect for premaking a script, config or text file", 5, 95) 
$Button4=GUICtrlCreateButton("Record an error", 5, 125, 100, 25)
GUICtrlCreateLabel("Records an error from a window as a file", 5, 150)
$Button5=GUICtrlCreateButton("Empty directory remover", 5, 175, 150, 25)
GUICtrlCreateLabel("Delete empty directories from any folder, includes sub dirs", 5, 200)

While 1
        $msg = GUIGetMsg()
        Switch $msg
        Case $Button1
        MsgBox(0, "Note From Author", "Thankyou for using my utilities collection" & @lf & @lf & "Special Thanks to:" & @lf & @lf & "KaFu:" & @LF & "code for empty directory remover")
        Exit
        Case $Button2
        randomnumber()
        Case $Button3
        filemake()
        case $Button4
        troubleshootwin()
        Case $Button5
        emptydirectoryrem()
        EndSwitch
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    GUIDelete()

Func randomnumber()
$LowerLimit = 1
$UpperLimit = 5500

$RandomNumber = Random($LowerLimit,$UpperLimit,1)

$randgui=GUICreate("RandomNumber", 100, 100)
GUISetState(@SW_SHOW)
GUICtrlCreateLabel($RandomNumber, 40, 5)
$Button1=GUICtrlCreateButton("Next", 20, 45)
$Button2=GUICtrlCreateButton("Exit", 60, 45)

While 1
        $msg = GUIGetMsg()
        Switch $msg
        Case $Button1
        GUIDelete($randGUI)
        randomnumber()
    Case $Button2, $GUI_EVENT_CLOSE
        GUIDelete($randgui)
        EndSwitch
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    GUIDelete()
EndFunc

Func Filemake()
    $input=inputBox("File Maker", "what file would you like to create?" & @lf & @lf & "Example: something.txt" & @lf & @lf & "Next window will let you choose where to save the file")

_FileCreate(FileSelectFolder("Save file to:", "", 7) & "\" & $input)
EndFunc

Func troubleshootWin()
$window=InputBox("error logger", "what is the title of the window appearing with the error?" & @lf & "Please type it exactly as you see the title, example: BiTComet or BITCOMET or bitcomet is not the same as BitComet")
$file=InputBox("Save Error As","what would you like to save the error recorded as?" & @lf & @lf & "Example: error.txt" & @lf & @lf & "Next window will let you choose" & @lf & "where to save the file")
$RecError=WinGetText($window)
$fsave=FileSelectFolder("Save error file to:", "", 7)

_FileCreate($fsave & "\" & $file)
FileWriteLine($fsave & "\" & $file, $RecError)
EndFunc

Func emptydirectoryrem()
    $ddnumber = 0
    
    _FileCreate(@desktopdir & "\empty directory removal results.txt")

$var = FileSelectFolder("Delete Empty directories from:", "", 7)
If @error Then Exit

$FileList = RecursiveFileSearch($var, "", "", 2, True)
If @error = 1 Then
    MsgBox(0, "", "No Files\Folders Found.")
    Exit
EndIf

;_ArrayDisplay($FileList)

For $i = 1 To $FileList[0]
    If StringInStr(FileGetAttrib($FileList[$i]), "D") Then; If parent (empty) dir has already been deleted, FileGetAttrib returns Blank and further analysis is skiped.
        If DirGetSize($FileList[$i]) = 0 Then
            If DirRemove($FileList[$i]) Then
                ConsoleWrite("Dir removed: " & $FileList[$i] & @CRLF)
                $ddnumber += 1
                FileWriteLine(@desktopdir & "\empty directory removal results.txt", $FileList[$i] & @CRLF)
            Else
                ConsoleWrite("Could not remove (empty?) dir: " & $FileList[$i] & @CRLF)
            EndIf
        Else
            ConsoleWrite("Dir not removed (contains files): " & $FileList[$i] & @CRLF)
        EndIf
    EndIf
Next

If $ddnumber = 0 Then
    MsgBox(0, "No empty directories", "No empty directories found")
Else
    MsgBox(0, "Results", $ddnumber & " empty directories removed, please see 'empty directory removal results.txt' on the desktop")
EndIf
EndFunc

Func RecursiveFileSearch($RFSstartDir, $RFSFilepattern = ".", $RFSFolderpattern = ".", $RFSFlag = 0, $RFSrecurse = True, $RFSdepth = 0)

;Ensure starting folder has a trailing slash
    If StringRight($RFSstartDir, 1) <> "\" Then $RFSstartDir &= "\"

    If $RFSdepth = 0 Then
    ;Get count of all files in subfolders for initial array definition
        $RFSfilecount = DirGetSize($RFSstartDir, 1)

    ;File count + folder count (will be resized when the function returns)
        Global $RFSarray[$RFSfilecount[1] + $RFSfilecount[2] + 1]
    EndIf

    $RFSsearch = FileFindFirstFile($RFSstartDir & "*.*")
    If @error Then Return

;Search through all files and folders in directory
    While 1
        $RFSnext = FileFindNextFile($RFSsearch)
        If @error Then ExitLoop

    ;If folder and recurse flag is set and regex matches
        If StringInStr(FileGetAttrib($RFSstartDir & $RFSnext), "D") Then

            If $RFSrecurse And StringRegExp($RFSnext, $RFSFolderpattern, 0) Then
                RecursiveFileSearch($RFSstartDir & $RFSnext, $RFSFilepattern, $RFSFolderpattern, $RFSFlag, $RFSrecurse, $RFSdepth + 1)
                If $RFSFlag <> 1 Then
                ;Append folder name to array
                    $RFSarray[$RFSarray[0] + 1] = $RFSstartDir & $RFSnext
                    $RFSarray[0] += 1
                EndIf
            EndIf
        ElseIf StringRegExp($RFSnext, $RFSFilepattern, 0) And $RFSFlag <> 2 Then
        ;Append file name to array
            $RFSarray[$RFSarray[0] + 1] = $RFSstartDir & $RFSnext
            $RFSarray[0] += 1
        EndIf
    WEnd
    FileClose($RFSsearch)

    If $RFSdepth = 0 Then
        ReDim $RFSarray[$RFSarray[0] + 1]
        Return $RFSarray
    EndIf
EndFunc  ;==>RecursiveFileSearch

if you have any suggestions for further Utilities, let me know

here is the download link for the already compiled application (Utils.exe)

enjoy

http://www.mediafire.com/?sharekey=a1f5b41...be6ba49b5870170

all feedback appreciated

Downloads: 10

Edited by snowman533

Intermediate AutoIt/Autohotkey User

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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