Recycle Bin Button With Status

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.

Aehm.. o) That button code is really messed up and mixes all kind of things, like regular button code (standalone GO command), script code and plain text (date at the bottom). It cannot work as expect. I suggest you download/extract the supplied zip-file and use the ready-to-use button from that (*.dcf file). Drag the *.dcf file to any toolbar while in customize mode. You also need to install the *.dis-file (the icons), use import from preferences -> toolbars -> icons.

Leo was quicker, but I still hit "submit" now! o)

I Removed the script and button and downloaded it again. This time the problem is the icon no longer shows that there is something in the recycle bin. No errors pop up.

What do the button and script look like now?

Which archive are you downloading? There are two in the thread from two different people.

Which version of Opus?

Hopefully this will answer all your questions.



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.1"
	initData.default_enable = True
End Function

' Called when a new Lister is opened
Function OnOpenLister(openListerData)
	Const RECYCLE_BIN = &Ha&
	Dim objShell
	Set objShell = CreateObject("Shell.Application")
	Dim objFolder
	Set objFolder = objShell.Namespace(RECYCLE_BIN)
	Dim colItems
	Set colItems = objFolder.Items
	Dim BinCount
	BinCount = 0
	Dim objItem
	For Each objItem in colItems
		if BinCount > 0 Then Exit For
		BinCount = BinCount + 1
	Next
	If BinCount > 0 Then
		dim objCmd : Set objCmd = DOpus.NewCommand
		'DOpus.Vars.Set ("Script.RecycleButton","isFull")
		objCmd.RunCommand("@set glob:RecycleButton=isFull") 
		'objCmd.RunCommand("@toggle:update") 
		Set objCmd = Nothing
	End If
End Function


That version of the script would only update the icon when a new lister opens.

Try the script in the root post, although I'm not sure if that's the best version of the multiple versions in this thread (the authors will have to tell you that, if there are still differences), it looks like it will update whenever a lister is made the active window, which is more often.

I did as Leo suggested and used the first posting in this thread and it works perfectly. Not sure why I read through all the other posts and concluded that I should use the "updated versions". Not clear why so many updates were offered in the first place. I'm just grateful to everyone that provides buttons and scripts. I can't write this stuff so I can't complain about why it can get so confusing. I do regret wasting Leo's time with dumb questions though. Thanks Leo!

I'm with you. There should be at least a version information and upload date whenever somebody fixes and enhances on things. Deciding what version to choose, if there are "latest" and "fixed" versions available which lack any description is not easy! o)

In the best case, snippets and uploads that are obsolete should also be removed and things to keep should move into the thread opening. Unfortunately not everyone seems to have fun maintaining their creations and threads.

I receive a script error when ever I start Directory Opus and open a new lister. Once I clear the script error, it doesn't return and the recycle bin works great. If I exit Directory Opus and restart it, The error returns. This is the error:
Script Output.txt (243 Bytes)

When I installed the script, I dragged the "testbin.vbs" into the preferences/tools/scripts box, but it didn't appear, however when I went to the script addons file, it was there.


This is the actual "testbin.vps" copied to a text file.
testbin.txt (889 Bytes)

I tried to figure out the problem on my own and I tried to contact the author, but I have had no success. I would very much like to learn how to work with scripts, but it might as well be written in ancient Sanskrit. Thanks for your attention.

Are you using Opus 11.13 or an earlier version?


:opusicon:

I assumed the posted script must work but having tried it, I get the same error, and I think there's a syntax error in the script. I'm not sure why "Call" is on either line near the bottom.

You may try this, I added the brackets which are needed when using "call" in vbs to fix the syntax error.
This is not tested and the current issue a bit weird actually, as how and why this worked before is quite unclear.

From my memory I'd say, there were some other issues which haven't been addressed, so be prepared for new issues or consider removing it from DO since the author does not show up anymore to maintain it.

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 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
		Call DOpus.vars.Set("Script.RecycleButton", "isFull")
	Else
		Call DOpus.vars.Delete("Script.RecycleButton")
	End If
End Function