Script help needed: clear selection; select current object

Both these questions apply to Power Mode

Is there a command in Directory Opus to clear the current selection?

Is there a command to select the current object (file or folder on which the caret is). What I want to do with this is to start a copy of the object the caret is on when I press F5 (like in Total Commander when you don't have to actually select an item you're caret-ing on when you want to copy it).

The two commands are Select NONE and Select THIS.

Thanks. It kind of works :wink:. I tried:

@script jscript function OnClick(data){ data.func.command.RunCommand("Select THIS"); data.func.command.RunCommand("Copy"); }

Unfortunately, this requires me to press F5 twice in order to work. First, it selects the object, but does not copy. Pressing F5 again copies it. Ideas? :slight_smile:.

The objects take a snapshot of things like the selected files at the start. If they change and you want the objects to use the new selections, you need to update them:

@script jscript function OnClick(data){ data.func.command.RunCommand("Select THIS"); data.func.command.sourcetab.Update(); data.func.command.SetFiles(data.func.command.sourcetab.selected_files); data.func.command.RunCommand("Copy"); }

Excellent. Thank you very much :slight_smile:.

Ah. Whoops. Doesn't work. Same thing. Gets selected but not copied.

Hm. Interesting. Now it does NOT copy even when I hit F5 a second time.

It worked here on a toolbar button. I didn't try on a hotkey but it should behave in the same way, as long as there isn't another hotkey on the same thing (F5 is the standard hotkey for "refresh", so that isn't impossible).

I deselected the other function of F5 (unchecked its checkbox).

The new script only selects items (just like the one I posted earlier) but unlike the earlier script, doesn't copy when I press F5 a second time.

I uploaded proof :smiley:.


Did you try with a file or a folder?

I think the script as it was would only copy files.

If you change selected_files to selected it should work with both:

@script jscript function OnClick(data){ data.func.command.RunCommand("Select THIS"); data.func.command.sourcetab.Update(); data.func.command.SetFiles(data.func.command.sourcetab.selected); data.func.command.RunCommand("Copy"); }

It was with a folder :slight_smile:. Now it works. Thanks a lot Leo :slight_smile:.