AutoHotkey Community

It is currently May 27th, 2012, 9:50 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: identify recycle bin
PostPosted: November 12th, 2006, 5:49 pm 
Offline

Joined: October 5th, 2006, 8:45 am
Posts: 476
how can I distinguish the two forms of recycle bin icon on desktop ? the "empty" and the "filled" recycle bin?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2006, 7:52 pm 
Offline

Joined: July 21st, 2006, 6:13 am
Posts: 558
Ok, this is what I came up with after doing a little bit of searching. :D
The script below will detect the status of the recycling bin for the current user.

Code:
Loop, HKEY_CURRENT_USER, Software\Microsoft\Protected Storage System Provider, 2
  SID = %A_LoopRegName%
Loop, C:\RECYCLER\%SID%\*.*, 1,
   FileFolderCnt = %A_Index%
If FileFolderCnt > 2
   MsgBox, The Recycle Bin is Full
Else
   MsgBox, The Recycle Bin is Empty


For some reason 2 files (desktop.ini and INFO2) are always kept in the C:\RECYCLER\%SID% directory, even if the recycling bin is emptied. BTW Im running Windows XP, so Im not sure if this works on other OS's.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2006, 10:14 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
It works on Windows 2000 as well.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2006, 10:34 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Here's another way (requires ExtractInteger()):
Code:
VarSetCapacity(rec, 64)
EnvGet, d, HomeDrive
DllCall("shell32.dll\SHQueryRecycleBinA", "Str", d, "UInt", &rec)
files := ExtractInteger(rec, 12, false, 4)
MsgBox, Number of files in recycling bin: %files%

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 12:56 am 
Offline

Joined: October 5th, 2006, 8:45 am
Posts: 476
thanks but

my intention was to actually empty recycle bin by right clicking on it...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 12:59 am 
Offline

Joined: July 21st, 2006, 6:13 am
Posts: 558
Then right click on it and empty it... :shock: :roll:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 2:38 am 
Offline

Joined: October 5th, 2006, 8:45 am
Posts: 476
aCkRiTe wrote:
Then right click on it and empty it... :shock: :roll:


:?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 2:41 am 
Offline

Joined: July 21st, 2006, 6:13 am
Posts: 558
Lol... :lol:

So you just want to be able to right click on the recycle bin once and empty it? Is that what your looking for?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 7:30 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear Titan, :)

Thanks for that DllCall(). I wanted to give it a try long ago and shyed away from it owing to the structure it required.
I had completely forgot about it until your post!

The following code is slightly improved to display the exact no.of objects as seen in Recycle Bin Window:

Code:
DriveGet, DriveList, List, Fixed
Loop PARSE, DriveList
   Objects += Recycled(A_LoopField . ":\")
MsgBox, % Objects
Return

Recycled(drv="") {
IfEqual, drv,, EnvGet, drv, HomeDrive
VarSetCapacity(rec, 64)
DllCall("shell32.dll\SHQueryRecycleBinA", Str, drv, UInt, &rec)
Return ExtractInteger(rec, 12, false, 4)
}

ExtractInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4) {
    Loop %pSize%  ; Build the integer by adding up its bytes.
        result += *(&pSource + pOffset + A_Index-1) << 8*(A_Index-1)
    if (!pIsSigned OR pSize > 4 OR result < 0x80000000)
        return result 
    return -(0xFFFFFFFF - result + 1)
}


:)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 11:54 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Goyyah, you code does the exact same thing as mine :?
Edit: oh I see, it's a function wrapper, nice :)

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 4:25 pm 
Offline

Joined: October 5th, 2006, 8:45 am
Posts: 476
can anyone tell me how to empty recycle bin with right click on it?

ofcourse the code it should click ok in the question, are you sure you want to delete these files


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 5:53 pm 
Offline

Joined: July 21st, 2006, 6:13 am
Posts: 558
I think you are looking for the command 'FileRecycleEmpty'.... This will empty the Recycle Bin...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 10:32 pm 
Offline

Joined: October 5th, 2006, 8:45 am
Posts: 476
wow very interesting

I didnt expect for a command like this to exist

how do I associate it with right click on recycle bin icon on desktop?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2006, 3:30 am 
Offline

Joined: July 21st, 2006, 6:13 am
Posts: 558
Wow! Ok to start off Im not trying to be mean or rude, but why the heck would you want to be able to just right click on the Recycle Bin once and it empty it, when you could just right click on it and select 'Empty Recycle Bin' from the list? :? I guess you just want to eliminate that very painful mouse movement and extra left click on 'Empty Recycle Bin'. Oh well... Anyways I have figured out EXACTLY what you have been asking for. So enjoy! :D :P

Code:
#SingleInstance Force
#Persistent
#NoEnv
SetBatchLines, -1
CoordMode, Pixel, Screen
SysGet, SM_CXICON, 11
SysGet, SM_CYICON, 12
ImageSearch, VarX, VarY, 0, 0, A_ScreenWidth, A_ScreenHeight, *150 *W%SM_CXICON% *H%SM_CYICON% *Icon33 C:\WINDOWS\system32\SHELL32.dll
SM_CXICON := VarX + SM_CXICON
SM_CYICON := VarY + SM_CYICON
CoordMode, Mouse, Screen
SetTimer, GetMouseCursorPos, 250
Return
GetMouseCursorPos:
MouseGetPos, VarXX, VarYY
If VarXX between %VarX% and %SM_CXICON%
   If VarYY between %VarY% and %SM_CYICON%
      {
         GetKeyState, State, RButton
         If State = D
            FileRecycleEmpty
      }
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2006, 5:04 am 
Offline

Joined: October 5th, 2006, 8:45 am
Posts: 476
aCkRiTe wrote:
Wow! Ok to start off Im not trying to be mean or rude, but why the heck would you want to be able to just right click on the Recycle Bin once and it empty it, when you could just right click on it and select 'Empty Recycle Bin' from the list? :? I guess you just want to eliminate that very painful mouse movement and extra left click on 'Empty Recycle Bin'.


really not wanting to be rude but...
I am so bored of such questions...

you can post such question "why the heck dont you do it manually?", "why you want to do such thing?" etc in the 99% of the posts of this forum

I think you can figure out the answer by yourself
yes, some people may get bored to make repeatitive tasks, isnt this the purpose of ahk anyway?

what you find useless, some others may find it useful
at least it wont hurt anyone

Quote:
Oh well... Anyways I have figured out EXACTLY what you have been asking for. So enjoy! :D :P

Code:
#SingleInstance Force
#Persistent
#NoEnv
SetBatchLines, -1
CoordMode, Pixel, Screen
SysGet, SM_CXICON, 11
SysGet, SM_CYICON, 12
ImageSearch, VarX, VarY, 0, 0, A_ScreenWidth, A_ScreenHeight, *150 *W%SM_CXICON% *H%SM_CYICON% *Icon33 C:\WINDOWS\system32\SHELL32.dll
SM_CXICON := VarX + SM_CXICON
SM_CYICON := VarY + SM_CYICON
CoordMode, Mouse, Screen
SetTimer, GetMouseCursorPos, 250
Return
GetMouseCursorPos:
MouseGetPos, VarXX, VarYY
If VarXX between %VarX% and %SM_CXICON%
   If VarYY between %VarY% and %SM_CYICON%
      {
         GetKeyState, State, RButton
         If State = D
            FileRecycleEmpty
      }
Return


really thanks but it doesnt seem to work for me
it does not empty the recycle bin by right clicking on the recycle bin icon on the desktop

PS:I hoped it wasnt that complicated...


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Maestr0, XstatyK and 59 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group