Folder/Drive Button

Overview
I use this script on many buttons in my setup.

Normal Click: changes the current tab to the path defined for the button.
Shift + Click: new tab to the path defined for the button.
Control + Click: new tab to the path defined for the button in the background.
Shift + Control + Click: new lister to the path defined for the button.
Control + Alt + Click: new tab in dual view to the path defined for the button.
Shift + Control + Alt + Click: new lister in dual view. Left side is the location of the previous window, right is path defined for the button.

How to use

  1. Create a new button.
  2. Change the type to 'Script Function' and then the Script Type to 'JScript':
    image
  3. Copy and paste in the code supplied below.
  4. In the quotation marks ("") after 'location' enter the path to your desired location:
    image
    IF YOUR LOCATION PATH HAS A BACKSLASH (\), YOU MUST REPLACE IT FOR TWO BACKSLASHES (\\). See below for an example:

INCORRECT
image

CORRECT
image

Code

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var location = "C:\\Example Path\\Example";
    var curLocation = clickData.func.sourcetab;

    switch (clickData.func.qualifiers) {
        case "none":
            cmd.RunCommand('Go "' + location + '"');
            break;
        case "shift":
            cmd.RunCommand('Go "' + location + '" NEWTAB');
            break;
        case "ctrl":
            cmd.RunCommand('Go "' + location + '" NEWTAB=nofocus');
            break;
        case "shift,ctrl":
            cmd.RunCommand('Go "' + location + '" NEW');
            break;
        case "ctrl,alt":
            cmd.RunCommand('Go "' + location + '" NEWTAB OPENINDUAL');
            break;
        case "shift,ctrl,alt":
            cmd.RunCommand('Go NEW=dualvert CURRENT DUALPATH "' + location + '"');
    }
}
2 Likes

Is there a way to do the same with the Driver Button "Go DRIVEBUTTONS=labels", without creating every single drive button?

What is an example of a use case for this?

The Go command's KEYARGS argument can be used to add extra arguments depending on which key is down.

That works with DRIVEBUTTONS and could also be used to do what's in the root post without scripting.

For example:

Go DRIVEBUTTONS=labels KEYARGS "ctrlalt:NEWTAB OPENINDUAL" "shift:NEWTAB" "ctrl:NEWTAB=nofocus"

More detail in the manual: Go [Directory Opus Manual]

3 Likes

Thank you, this worked for me!

At the top of my DOpus window I have a series of buttons which use this script I made so I can easily access drives and folders:

Forgive me for not knowing, what are 'driver buttons'?

Drive not driver. They’re buttons which go to drives, one for each drive letter.

1 Like