GP SoftwareTwitter
Opus FAQsManualCommandsObjects

How to use buttons and scripts from this forum

scripting
button

#1

For how to use Script Add-Ins, please see the reply to this post.

This first post covers Buttons and Toolbars, and also applies to raw commands for things like standalone hotkeys.

Buttons and toolbars can be shared in several different ways.

(Much of this assumes Directory Opus Pro. While Opus Light does have the ability to edit some toolbars, it is not a focus of the Light version and much less extensive.)


Raw Commands

Posts often contain commands which you can put in a button, hotkey or menu. For example:

Copy INSTALLFONT

To create a toolbar button which runs that command:

  1. Select Settings -> Customize Toolbars (the Customize window will open; keep it open but move it out of the way)
  2. Back in the main window, right-click your toolbar somewhere and (depending on where you clicked) there will be a New or Insert New sub-menu. Click that sub-menu, and then New Button.
  3. Right-click the button that was just added and choose Edit. (Or double-click the button.)
  4. For single-line commands: Paste the command into the Function field.
    For multi-line commands: Click the Advanced button, then paste the command into the big area at the bottom.
  5. Click OK in the button editor, then OK in the Customize window.

For more details, see Editing the Toolbar in the Opus manual.


XML Button Definitions

Some posts contain blocks of XML which define all aspects of a button (or even a menu containing several buttons).

These blocks of XML define not just the command (like in the Raw Commands example above), but also the button's icon, label and other attributes.

Don't worry, you don't need to know anything about XML. You just need to copy the text and paste it to your toolbar to create the button.

Here is an example:

<?xml version="1.0"?>
<button display="both" separate="yes">
	<label>Install Font</label>
	<icon1>#otherplugins</icon1>
	<function type="normal">
		<instruction>Copy INSTALLFONT</instruction>
	</function>
</button>

(What the button does isn't important for this explanation but, if you are wondering, it installs any selected font files into your system.)

Here's how to take the code box above and turn it into a button in a toolbar or menu:

  1. In your web browser, select everything in the code box and copy it to your clipboard.

  2. Switch to Opus and enter Customize mode via the menu: Settings -> Customize Toolbars

    The Customize dialog will open and your toolbars and menus may change appearance slightly.

  3. Find where you want to put the new button in your toolbars or menus, then right-click that place and select Paste.

    (The screenshot shows the menu you get if you right-click an empty part of the toolbar. You'll get a slightly different menu if you right-click one of the buttons on the toolbar. In either case, you still want the same Paste item.)

    The button will have been added to your toolbar or menu.

  4. (Optional)

    While in Customize mode you can move and edit your buttons and menus:

    • To move buttons simply drag them around.
    • To create a separator bar between two buttons, drag one slightly away from the other until a marker appears.
    • To change the appearance of a button, for example to remove the label or put the label in a different place, right-click the button and select Edit (or double-click it).
  5. Click OK in the Customize dialog to exit Customize mode and save your changes.

    The new button is now ready to use.

(See also: Sharing functions with others, in the Opus manual.)


Toolbar .dop Files

A few posts contain entire toolbars, in .dop files. To load one, simply double-click it and Opus will import it.


Button .dcf Files

Individual buttons can be stored as .dcf files by dragging them to your desktop while in Customize mode.

These files are great for keeping a library of buttons on your computer, but rarely used on the forum where it is more convenient to share the XML versions, seen above. (If you open a .dcf file in a text editor, you'll see it is similar to the XML codes shared on the forum. It's really just another way of storing the same data.)

On the forum, .dcf files are usually only used for buttons which are bundled with other things in zip archives.

To add a button from a .dcf file to your toolbar:

  1. Navigate to where the .dcf file is. (If it is inside a zip, extract it first.)
  2. Select Settings -> Customize Toolbars.
  3. Drag the .dcf file to your toolbar.
  4. Click OK in the Customize window.

(Note: If you double-click a .dcf file it will run the commands inside it.)


Scripts: Continue to the post below...


Toolbar button that can NAME a created zip file on the fly?
How do you display actual number of bytes in Size column?
Refresh folder tree, not just lister
Lister in Admin Mode, programs not elevated
RegExp basics: Removing characters from start/end of names
"<?xml" not found - can't use Tera Copy with toolbar button
Directory sort order
Dopus with Virtual Dub button
Need help with a button!
Can i save selection state?
Copy path to text file, then create zip?
XML Help -
Select only the same files
Obtaining text from an existing text file
Obtaining text from an existing text file
Dots to spaces except in numbers. (For files and folders.)
Text extraction in viewer plugin
Register or Unregister DLL or OCX
Adding Explorer Search Command
SELECT Field: Partial Match; Deselect
"Create File" option?
Creating folders from filename
Find duplicate filenames with different extensions
How to close the FIND dialog from a button
Combo box which contains all drive letters (like TC)?
Questions about TeraCopy and Directory Opus
Questions about TeraCopy and Directory Opus
Rename Parent Folder as Selected File/Folder (or vice versa)
XML code . How to use
RegExp basics: Removing characters from start/end of names
Trouble Saving Layouts
Trouble Saving Layouts
Request: Favorite Feature
Copy & Move with TeraCopy
Copy and change date
Feature request: stop the focus stealing "insert a disk"
Copy paths of selected files to clipboard
Save current layout
Hide System Files
Hide System Files
SELECT user command
Renaming + numbering multiple files?
Recursive copy/rename function
Renaming files
Is there a Copy To... that will create a folder?
Manual ftp get and chdir
Help needed for creating a special copy-create folder button
Create Dated Zip
Start Menu button
EditBOM - Command to add, remove or toggle UTF-8 byte-order-mark
New Folder Drop Down Button
How do I make my style looks like this?
LinkedTab_AutoClose_Handler: Auto-close linked tabs
LinkedTab_AutoOpen_Handler: Open related folder tabs automatically
Synchronising files of different types
Dynamic SWITCHPATH v2.2
Create .m3u playlist file from dir contents
Column sizes in Commander View
Help creating a dialog input, please
Help creating a dialog input, please
SmartGetSizes_Handler: Toggle automatic folder size calculation
Why are my Opus windows on-top?
Button to move files in folder named from file
Delete or rename non-matching files only
Sort dd-mm-yyyy
Customize Lister window title
Script to covert text files (e.g. srt) into UTF-8, without BoM
Copying Files to changes Owner Name? :S
"Play All" audio functionality is missing
Work Offline / Online button?
Windows 8 File History
MTP & Set FOCUS=Dest command
Updating Many files that have the same name
Updating Many files that have the same name
Thumbnail size override
Beyond Compare buttons
Feature: "Take Ownership" of a file or folder?
Batch rename *and* copy or move the files in one go?
Yes/no Dialogue with variables in CMD
Moving pictures and videos within Sub-folders
Making the FIND window close as soon as it has done its job
How to restore FTP menu?
Export directory structure to txt
Help with Clipboard Copyname button
"Move to new folder" Button
TV Episode XBMC Renamer
Copy into multiple selected destinations
How to Put favorite label and status icons in the top toolbar
Swap the names of two files
How to Put favorite label and status icons in the top toolbar
Modify Rename menu item script
Script to take micro4/3 (MFT) Focal Length & fill 35mm column
Focus of Lister Files
Copy & Move with TeraCopy
How to install fonts
New user switching from Total Commander
Duplicate current lister
Layout_UpdateOnClose_Handler: Automatically save non-default layouts when closing listers
Editing a MS-DOS batch function
Layout_AutoOpen_Handler: Open a saved lister layout when opening trigger folder
Individual manual headline text per Lister window
Insert new text file "info.txt" by shortcut?
RAW and JPEG preview selection
Close all listers except source and destination
Copy & Move with TeraCopy
Keep on Top
PDF-Toolkit Menu (PDF merge, extract, protect, unprotect, organize)
7zip - Copy As [Directory]
Sort music files and go to the target folder
V12 - Multiple status icons and stacked labels not working for me
Command for Alias listing?
Button: Random Shuffle
How to copy file contents from the context menu
Text file line count
Help Menu has disappeared
Help Menu has disappeared
DO Archives
"Play All" audio functionality is missing
"Play All" audio functionality is missing
Long delay when right-clicking 39,000 files
Copy files to specific folders
CBX_Handler: Comic Book Reader
NavSync - an alternative to NavLock
Directory Opus config paths checker (DOChecker)
Open folder of flat filtered file
Scrollable list of drives to select from
Collection by Label and Reorder Labels
'Bookmark' file or 'go to' Last viewed file option?
Determine & add correct file extensions
How to add file and folder direct shortcuts in the top toolbar?
SetAttr from Clipboard date
Documentation suggestion -- ">" to get a command box
Changing The Cache Location On Our New System
File rename control arrows
Folder Tree Question
Label Colour on Toolbar?
Can I add a Dual Horizontal Lister button to my toolbar
WinRAR Compress/Decompress Buttons (and other)
How to move the thumbnail cache
List of FAQs organised by topic
How to save a dual display as a default layout
Command: ClipAttr (copy/paste timestamps between files)
ZIP compression level ignored
How to set up a Quick Filter menu
Renaming + numbering multiple files?
Deleted Shortcut
TheMovieDB Poster&Info Downloader V2.0
How to create folder name with tomorrow(next date)?
Metadata copy from one field to another
TortoiseSVN Buttons
Command: Go-Relative (go to next/prev sibling folder)
Locked tabs which can only navigate to sub folders
Possible To Check For Folder/File in .ZIP File?
GoParallel - Jump between related folder trees
Find Duplicates - Different Names - Same Size - No MD5 hashing
Quickly find shell property names
Show first selected file
Easy way to make files 0 KB with a button?
Folder Tree to display only a designated folder and its contents
Button to open same PDF file with changing index number?
'Fetch' command: Find and copy related files
Sort Folder Tabs (on-demand, or when listers open)
Drive test button
How to use Rename Presets from this forum
Question - Paste same file to different folders
Script to Populate Summary Properties
Hotkey for Edit a file
"File Not Found" Issue when opening files
Date format for dated folder
GetExtendedFileAttributes
Refine synchronisation
Copy sequential folder with increment
Open new lister with a specific Folder Format?
Open new lister with a specific Folder Format?
#2

Scripts

Scripts are usually written in JScript (a version of Javascript) or VBScript.

Scripts may be shared on the forum in a few different ways.


Script Buttons

These are like regular toolbar buttons, except they contain script code.

If they are shared as XML code or .dcf files then you can add them to your toolbars the same as you would a button containing non-script commands. See the XML Button Definitions and Button .dcf Files sections of the post above for how do that.

If someone posts some raw script code which starts with an OnClick method, that is usually intended to be placed in a button.

For example, here is some simple JScript that goes in a button:

function OnClick(clickData)
{
	DOpus.Output("Hello World");
}

Creating a new button to run that script is exactly the same as the Raw Commands part of the post above, with two extra steps:

  1. When you edit the empty button, set the Function drop-down to Script Function.
  2. Change the Script Type drop-down to JScript or VBScript as appropriate.

Before Opus 12, instead of the Script Type drop-down, scripts in buttons would begin with a line like:

@script jscript

That served the same purpose as the drop-down. (In fact, that line is still there behind the scenes, and you'll see it if you look at the button's XML code. The button editor UI just turns the line into a nicer drop-down.)


Rename Scripts and Presets

Rename scripts will typically be provided as part of a Rename Preset (.orp file), which can be imported into the Rename dialog.

See the separate topic, How to use Rename Presets from this forum.


Script Add-Ins

Script Add-Ins are like extensions or plug-ins for Opus, written in a scripting language. They can add custom commands to use in buttons, and custom columns to show in the file display. They can be triggered on events (e.g. changing folders) and alter the way Opus behaves. And various other things.

Script Add-Ins are managed under Preferences / Toolbars / Scripts.

If you look at the code for a Script Add-In, it will almost always have an OnInit function, usually near the top.

There are three ways someone might share a Script Add-In on the forum:

  1. As a downloadable script file, usually with a .js.txt or .vbs.txt extension.

    To install these, simply download them, then drag & drop the file to the list of scripts in Preferences / Toolbars / Scripts.

    You might want to open the script in a text editor first, to get an idea of what it does.

    Remember, scripts can do absolutely anything to your computer. Buttons can as well, but it's a lot easier to hide something in a script. It is worth looking at what you are about to run.

    If you install the script using drag & drop, you'll notice that Opus removes the .txt extension. Opus doesn't care if the extension is .js.txt or just .js but will remove the .txt part to tidy things up.

    The reason the .txt part is added is that most web browsers and anti-virus won't let you download files with script extensions, and it also prevents you from accidentally double-clicking the script and running it outside of Opus, which would not work.

  2. As a downloadable script package, with a .osp extension:

    These are pretty rare, but may be used when a script needs to come packaged with icons or other resources in addition to the script itself.

    Installation is the same as above. Just drag the .osp file to the list of scripts in Preferences / Toolbars / Scripts.

    If you want to look inside the .osp file before installing it, simply rename it to .zip and then open it like a normal archive.

  3. As script code pasted into a message:

    Some posts include both a downloadable version of the script, and the script code in the post itself.

    If you have both options, the downloadable version is easiest to use, and the other version is there because it's easiest to read. (Sometimes people browse the forum for scripting techniques, not for scripts to install and use.)

    If a post has no downloadable version of a script add-in, and just contains the script code in the post itself, then you should do the following:

    • Copy the script code to the clipboard.

    • Go to Opus and push Ctrl-V to paste the clipboard contents into a new file.

      (The file will be called Clipboard Text.txt, at least in English versions of Opus.)

    • Rename the new file to something unique that matches what the script is about.

    • Give the new file a .js.txt or .vbs.txt extension as appropriate.

      (If the poster hasn't said which language the script is in, the forum often works it out for you and puts a "js" or "vbs" watermark at the top-right of the code box. If the poster has not used a code box, js scripts typically contain the word "var" in a few places and lots of { } brackets, while vbs scripts typically contain the word "dim" in a few places and lots of "begin" and "end".)

    You can then drag the script file to the list of scripts in Preferences / Toolbars / Scripts.

    You might also want to complain to the person who posted it for not providing an easier to use version. :slight_smile:


How to install JScript describe in Copy Selected Filenames
"Unknown" format for folders not loaded at startup?
TV Episode XBMC Renamer
Select folders which (sub)folder(s) contains certain file?
#3

Rename and overwrite button
Convert Date Format (ISO 8601 <=> DIN 1355)
Remove characters from selected folder and file names
Insert text into file names
File name to modified date/time?
Calculate folder sizes?