 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
user
Joined: 05 Oct 2006 Posts: 424
|
Posted: Sun Nov 12, 2006 5:49 pm Post subject: identify recycle bin |
|
|
| how can I distinguish the two forms of recycle bin icon on desktop ? the "empty" and the "filled" recycle bin? |
|
| Back to top |
|
 |
aCkRiTe
Joined: 21 Jul 2006 Posts: 552
|
Posted: Sun Nov 12, 2006 7:52 pm Post subject: |
|
|
Ok, this is what I came up with after doing a little bit of searching.
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 |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 2952 Location: Minnesota
|
Posted: Sun Nov 12, 2006 10:14 pm Post subject: |
|
|
| It works on Windows 2000 as well. |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5043 Location: /b/
|
Posted: Sun Nov 12, 2006 10:34 pm Post subject: |
|
|
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) • PlusNet • Scripts • IronAHK • Contact by email not private message. |
|
| Back to top |
|
 |
user
Joined: 05 Oct 2006 Posts: 424
|
Posted: Mon Nov 13, 2006 12:56 am Post subject: |
|
|
thanks but
my intention was to actually empty recycle bin by right clicking on it... |
|
| Back to top |
|
 |
aCkRiTe
Joined: 21 Jul 2006 Posts: 552
|
Posted: Mon Nov 13, 2006 12:59 am Post subject: |
|
|
Then right click on it and empty it...  |
|
| Back to top |
|
 |
user
Joined: 05 Oct 2006 Posts: 424
|
Posted: Mon Nov 13, 2006 2:38 am Post subject: |
|
|
| aCkRiTe wrote: | Then right click on it and empty it...  |
 |
|
| Back to top |
|
 |
aCkRiTe
Joined: 21 Jul 2006 Posts: 552
|
Posted: Mon Nov 13, 2006 2:41 am Post subject: |
|
|
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? |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 7187
|
Posted: Mon Nov 13, 2006 7:30 am Post subject: |
|
|
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)
} |
 _________________ Suresh Kumar A N |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5043 Location: /b/
|
Posted: Mon Nov 13, 2006 11:54 am Post subject: |
|
|
Goyyah, you code does the exact same thing as mine
Edit: oh I see, it's a function wrapper, nice  _________________ Chat (IRC) • PlusNet • Scripts • IronAHK • Contact by email not private message. |
|
| Back to top |
|
 |
user
Joined: 05 Oct 2006 Posts: 424
|
Posted: Mon Nov 13, 2006 4:25 pm Post subject: |
|
|
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 |
|
 |
aCkRiTe
Joined: 21 Jul 2006 Posts: 552
|
Posted: Mon Nov 13, 2006 5:53 pm Post subject: |
|
|
| I think you are looking for the command 'FileRecycleEmpty'.... This will empty the Recycle Bin... |
|
| Back to top |
|
 |
user
Joined: 05 Oct 2006 Posts: 424
|
Posted: Mon Nov 13, 2006 10:32 pm Post subject: |
|
|
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 |
|
 |
aCkRiTe
Joined: 21 Jul 2006 Posts: 552
|
Posted: Tue Nov 14, 2006 3:30 am Post subject: |
|
|
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!
| 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 |
|
 |
user
Joined: 05 Oct 2006 Posts: 424
|
Posted: Tue Nov 14, 2006 5:04 am Post subject: |
|
|
| 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!
| 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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|