Sign in to follow this  
Followers 0
WeMartiansAreFriendly

recycle bin functions

4 posts in this topic

heres some functions i just whipped up, _FileRecycleBinGetSize() returns the amount of space the files in there are taking up in KB's, it should be accurate and as far as i know, (i've looked everywhere) theres no other way to see how much space it's taken up.. so this might be useful.

the other one _FileRecycleBinGetContents() returns a 2 deminsional array with all files in the recycle bin, and some extended info, e.g. date deleted, filesize, ect..

i might look into more functions later, or whatever anyways..

big thanks to the guys who helped in this topic: http://www.autoitscript.com/forum/index.php?showtopic=43168

ok off to bed.. : :whistle:

msgbox(0,'Recycle bin size', _FileRecycleBinGetSize() & " KB")

$reccon = _FileRecycleBinGetContents()

For $y = 1 To  $reccon[0][0]
    
    Msgbox(0,'Recyclebin contents', _
            $reccon[$y][0] &@lf& $reccon[$y][1] &@lf& _
            $reccon[$y][2] &@lf& $reccon[$y][3] &@lf& _
            $reccon[$y][4] &@lf& $reccon[$y][5] &@lf& _
            $reccon[$y][6] &@lf& $reccon[$y][7] &@lf& _
            $reccon[$y][8] &@lf& $reccon[$y][9] &@lf& _
            $reccon[$y][10] &@lf )
    If $y = 10 Then ExitLoop
Next
 

Func _FileRecycleBinGetSize()
    Local Const $RECYCLE_BIN = 10 
    Local Const $FILE_SIZE = 3
    Local $objShell = ObjCreate("Shell.Application")
    Local $objFolder = $objShell.Namespace($RECYCLE_BIN)
    Local $colItems = $objFolder.Items
    Local $strSize, $intSize, $arrSize
    If IsObj($objShell) And Not @error Then
        For $objItem in $colItems
            $strSize = $objFolder.GetDetailsOf($objItem, $FILE_SIZE)
            $intSize += StringRegExpReplace($strSize,'\D','')
        Next
        Return $intSize
    EndIf
    Return SetError(1,0,-1)
EndFunc

Func _FileRecycleBinGetContents()
    Local Const $RECYCLE_BIN = 10
    Local $objShell,$objFolder,$objFolderItem, $colItems
    Local $aArray[2][15], $y = 1
    $objShell = ObjCreate("Shell.Application")
    $objFolder = $objShell.Namespace($RECYCLE_BIN)
    $objFolderItem = $objFolder.Self
    ;MsgBox (0, "", $objFolderItem.Path)
    $colItems = $objFolder.Items
    If IsObj($objShell) And Not @error Then
        For $objItem in $colItems
            $aArray[$y][0] = $objItem.Name
            $aArray[$y][1] = $objFolder.GetDetailsOf($objItem, 1) ;name
            $aArray[$y][2] = $objFolder.GetDetailsOf($objItem, 2) ;original location
            $aArray[$y][3] = $objFolder.GetDetailsOf($objItem, 3) ;Size
            $aArray[$y][4] = $objFolder.GetDetailsOf($objItem, 4) ;file type
            $aArray[$y][5] = $objFolder.GetDetailsOf($objItem, 5) ;date modified
            $aArray[$y][6] = $objFolder.GetDetailsOf($objItem, 6) ;date deleted
            $aArray[$y][7] = $objFolder.GetDetailsOf($objItem, 7) ;date accessed?
            $aArray[$y][8] = $objFolder.GetDetailsOf($objItem, 8) ;file attribs
            $aArray[$y][9] = $objFolder.GetDetailsOf($objItem, 9) ;status
            $aArray[$y][10] = $objFolder.GetDetailsOf($objItem, 10) ;owner
            $y += 1
            ReDim $aArray[$y+1][15]
            $aArray[0][0] = UBound($aArray)-1
        Next
        Return $aArray
    EndIf
    Return SetError(1,0,$aArray)
EndFunc

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites



Looks very nice! Thanks.


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

You could also add a repair function in there for when Windows messes it up.

I have not even thought about the code but here is the basics

For all Fixed drives

If Win 9x the the folder is 'Recycled' if its XP the folder is 'Recycler'

Remove the folders System Attrib

Deltree the folder

Force a restart

Presto! fixed


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

nice

Edited by c4nm7

Share this post


Link to post
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
Sign in to follow this  
Followers 0