AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

identify recycle bin
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
user



Joined: 05 Oct 2006
Posts: 424

PostPosted: Sun Nov 12, 2006 5:49 pm    Post subject: identify recycle bin Reply with quote

how can I distinguish the two forms of recycle bin icon on desktop ? the "empty" and the "filled" recycle bin?
Back to top
View user's profile Send private message
aCkRiTe



Joined: 21 Jul 2006
Posts: 552

PostPosted: Sun Nov 12, 2006 7:52 pm    Post subject: Reply with quote

Ok, this is what I came up with after doing a little bit of searching. Very Happy
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.
Back to top
View user's profile Send private message
jonny



Joined: 13 Nov 2004
Posts: 2952
Location: Minnesota

PostPosted: Sun Nov 12, 2006 10:14 pm    Post subject: Reply with quote

It works on Windows 2000 as well.
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5043
Location: /b/

PostPosted: Sun Nov 12, 2006 10:34 pm    Post subject: Reply with quote

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%

_________________
Chat (IRC)PlusNetScriptsIronAHK Contact by email not private message.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
user



Joined: 05 Oct 2006
Posts: 424

PostPosted: Mon Nov 13, 2006 12:56 am    Post subject: Reply with quote

thanks but

my intention was to actually empty recycle bin by right clicking on it...
Back to top
View user's profile Send private message
aCkRiTe



Joined: 21 Jul 2006
Posts: 552

PostPosted: Mon Nov 13, 2006 12:59 am    Post subject: Reply with quote

Then right click on it and empty it... Shocked Rolling Eyes
Back to top
View user's profile Send private message
user



Joined: 05 Oct 2006
Posts: 424

PostPosted: Mon Nov 13, 2006 2:38 am    Post subject: Reply with quote

aCkRiTe wrote:
Then right click on it and empty it... Shocked Rolling Eyes


Confused
Back to top
View user's profile Send private message
aCkRiTe



Joined: 21 Jul 2006
Posts: 552

PostPosted: Mon Nov 13, 2006 2:41 am    Post subject: Reply with quote

Lol... Laughing

So you just want to be able to right click on the recycle bin once and empty it? Is that what your looking for?
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 7187

PostPosted: Mon Nov 13, 2006 7:30 am    Post subject: Reply with quote

Dear Titan, Smile

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)
}


Smile
_________________
Suresh Kumar A N
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5043
Location: /b/

PostPosted: Mon Nov 13, 2006 11:54 am    Post subject: Reply with quote

Goyyah, you code does the exact same thing as mine Confused
Edit: oh I see, it's a function wrapper, nice Smile
_________________
Chat (IRC)PlusNetScriptsIronAHK Contact by email not private message.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
user



Joined: 05 Oct 2006
Posts: 424

PostPosted: Mon Nov 13, 2006 4:25 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
aCkRiTe



Joined: 21 Jul 2006
Posts: 552

PostPosted: Mon Nov 13, 2006 5:53 pm    Post subject: Reply with quote

I think you are looking for the command 'FileRecycleEmpty'.... This will empty the Recycle Bin...
Back to top
View user's profile Send private message
user



Joined: 05 Oct 2006
Posts: 424

PostPosted: Mon Nov 13, 2006 10:32 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
aCkRiTe



Joined: 21 Jul 2006
Posts: 552

PostPosted: Tue Nov 14, 2006 3:30 am    Post subject: Reply with quote

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? Confused 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! Very Happy Razz

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
Back to top
View user's profile Send private message
user



Joined: 05 Oct 2006
Posts: 424

PostPosted: Tue Nov 14, 2006 5:04 am    Post subject: Reply with quote

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? Confused 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! Very Happy Razz

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...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group