Recycle Bin Button With Status

This is the button code:

@iconp:MyBinFull,$glob:RecycleButton
Go /trash

The only difference is in the testbin script.

You Have:

   If objFolder.Items.Count > 0 Then
      Call DOpus.vars.Set( "Script.RecycleButton", "isFull")
   End If

and I have:

	If objFolder.Items.Count > 0 Then
		dim objCmd : Set objCmd = DOpus.NewCommand
		objCmd.RunCommand("@set glob:RecycleButton=isFull") 
		Set objCmd = Nothing
	End If

But my code shows the correct button icon when a new lister is opened.

Thanks for the tips @tbone. My scripting discipline leave much to be desired...lol

So it works now or.. ?

lol..yes indeed, but without the

Call DOpus.vars.Set( "Script.RecycleButton", "isFull")

Line. I can't seem to make it work with that. But bottom line... it works :wink:

It should work with that line as well, you just need to make sure to correctly use "Script.RecycleButton" as variable name in your buttons, including the "Script." part, as it is part of the variable name and not something to be omitted when used in a button or elsewhere.

Aaaah, I can see where I went wrong now. I just tried it with

Call DOpus.vars.Set( "RecycleButton", "isFull")

Because all my buttons codes uses RecycleButton only, not Script.RecycleButton.

I'm off to bed now, but I will upload a version tomorrow where all buttons and scripts refer to Script.RecycleButton

Thanks for all your help @tbone

My pleasure, giving help is easy if it's welcome. o)

Must ask a little offtopic question here, what is that "ShowInViewerpane" script I saw in your script-list screenshot? I'm looking for something to control the viewerpane, so wondered what it is. o)

If the recycle bin is full and you empty it at another place (e.g. using the context menu of the desktop icon) the icon will not update. You should add something like this at the end:

	If BinCount > 0 Then
		dim objCmd : Set objCmd = DOpus.NewCommand
		objCmd.RunCommand("@set glob:RecycleButton=isFull") 
		objCmd.RunCommand("@toggle:update") 
		Set objCmd = Nothing
	Else 	
		DOpus.vars.Delete ("RecycleButton") 
	End If
End Function

Instead of Function OnOpenLister(openListerData) I'm using Function OnActivateLister(ActivateListerData). This updates the icon more easily if something was deleted outside DOpus by e.g. toggleing source/dest.

@kundal, thanks for the feedback. I have updated the script to work on Function OnActivateLister(ActivateListerData). This has the added advantage that the icon is imediately updated if you delete via the context menu as well. I have also implemented all of @tbone's suggestions.

I have quickviewplus installed, but whether you have it or not, I find it way quicker to open a variety of files in the viewer rather than its registered program.

To do that, I edit the double-click event for the filetype and let it run the custom command ShowInViewerPane.
It also changes some layout settings that makes it easier for me to select another file to view in the viewer.

I removed some unnecessary lines from your script and made some minor changes:[code]option explicit

' TestBin
' 
' This is a script for Directory Opus.
' See http://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.
' 

' Called by Directory Opus to initialize the script
Function OnInit(initData)
	initData.name = "TestBin"
	initData.desc = "Updates the recycle bin button"
	initData.copyright = "goselito on 01/09/2014"
	initData.version = "1.2"
	initData.default_enable = True
End Function

' Called when a Lister is activated
Function OnActivateLister(ActivateListerData)
	Const RECYCLE_BIN = &Ha&
	Dim objShell
	Set objShell = CreateObject("Shell.Application")
	Dim objFolder
	Set objFolder = objShell.Namespace(RECYCLE_BIN)

	If objFolder.Items.Count > 0 Then
		DOpus.vars.Set "Script.RecycleButton", "isFull"
	Else
		DOpus.vars.Delete "Script.RecycleButton"
	End If
End Function

@goselito
Thanks for showing the ShowInViewerPane-thing, unfortunately it does not what I was looking for, but thanks alot! o)
(Maybe you should clear that post to not unnecessarily mix this thread up? Additionally I suggest removing all script snippets once this reaches a usable state.)

Another thought: Think about people not using the recycle-bin (they might have disabled it completly), how is your script going to handle that, I'd expect it to throw an error, don't know for sure. But Set objFolder = objShell.Namespace(RECYCLE_BIN) could fail then, so there's room for some "on error goto " stuff I guess. You probably also could switch to a "recycle-bin" disabled icon! Huh? o))

Wonder though, why is it actually important for you, to see that there are items in the bin? I normally don't care at all. o)

Thanks @kundal,

I've uploaded a new zip file with the changes.

You're welcome... I removed the code from that post.

It does not really make sense to me that anyone who disabled the recycle bin would want to have such a button :neutral_face:

I just did this as a proof of concept. I saw another post where people requested a recycle bin button with status update, then I remember reading about the @icon command modifier, so I thought why not try it.

Current script returns errors and icons are not updated.

Here is a fix version:
RecycleBin.zip (28.9 KB)

I installed the script and button and it works well. I am having a minor problem when when going to the recycle bin using the button. Windows 8.1 pops up a warning, "Windows cannot find Dim. Make sure you typed the name correctly and try again." Is it a problem with the script, or the button? Thank you for your efforts.


If you edit the button you are pushing, what does it show?

Looks like the button type is not set to "script function"?

That seems likely. But none of the buttons I can find in this thread start with a "dim" so there may be more to it than that.

I tried to customize the buttons from standard function to script mode, but the result was script errors. Going back to standard function and they both work great except for the error pop up. Thanks for your attention!


This is the script I installed.

option explicit

' TestBin
' 
' 
' This is a script for Directory Opus.
' See [gpsoft.com.au/DScripts/redir ... ge=scripts](http://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts) for development information.
' 
' 
' 
' Called by Directory Opus to initialize the script
Function OnInit(initData)
	initData.name = "TestBin"
	initData.desc = "Updates the recycle bin button"
	initData.copyright = "goselito on 01/09/2014"
	initData.version = "1.2"
	initData.default_enable = True
End Function

' Called when a new Lister is opened
Function OnActivateLister(ActivateListerData)
	Const RECYCLE_BIN = &Ha&
	Dim objShell
	Set objShell = CreateObject("Shell.Application")
	Dim objFolder
	Set objFolder = objShell.Namespace(RECYCLE_BIN)

   If objFolder.Items.Count > 0 Then
      dim objCmd : Set objCmd = DOpus.NewCommand
      objCmd.RunCommand("@set glob:RecycleButton=isFull")
      objCmd.RunCommand("@toggle:update")
      Set objCmd = Nothing
   Else
      DOpus.vars.Delete ("RecycleButton")
   End If
End Function

The button seems to have a jumble of the command it's meant to have, then part of the script, then today's date.

Did you edit the toolbar file by hand in a text editor? That's not the way to import a .dcf button file; instead, just drag the .dcf file to your toolbar while in Customize mode.