ClipCopy (Copy stuff to the clipboard)

ClipCopy copies stuff to the clipboard. What is copied is determined by parameters.

Parameters

ClipCopy COLUMNS

Copies the current column setup in the syntax of Set COLUMNSTOGGLE. Can be directly pasted into a button to toggle columns. Useful to save setups and consolidate folder formats.

ClipCopy DESCRIPTION

Copies the description of all selected items. One line per item.

ClipCopy FILEASBITMAP

Copies the first selected item via the viewer as a bitmap (not as a file). Useful to paste e.g. into Word documents.

ClipCopy NAMEANDCLOUDLINK

Loops through selected items and checks their availability in cloud storage. Copies the names and links in separate lines. Useful if you want to distribute links to more than one item and don't want to start a clicking frenzy. Cloud storage often reacts slowly, so the script waits for up to four seconds per item.

If you want to use Google Drive and your system's language is not English you need to pick the right language in the script. If your language is missing run ContextMenu SHOWCMDS on an item in Google Drive, look for the Label, and edit the script. Don't forget to share your findings!

Currently supported: Dropbox, Google Drive, OneDrive, Mega

ClipCopy NAMEANDDESCRIPTION

Copies name and description of all selected items. One line per item, separated by tab.

ClipCopy NAMEANDPRODVERSION

Copies name and product version of all selected items. One line per item, separated by tab. Useful for .com, .exe, and .dll files.

ClipCopy NAMEANDSIZE

Copies name and size in bytes of all selected items. One line per item, separated by tab.

ClipCopy NAMEANDSIZEAUTO

Copies name and size in bytes of all selected items. The size will be autoformatted by Opus standards (KB, MB, GB). One line per item, separated by tab.

ClipCopy NAMEANDTARGET

Copies name and target of all selected items. One line per item, separated by tab. Useful for .url and .lnk files.

ClipCopy OSMLINK

Creates http links to OpenStreetMap for all selected images that contain GPS data. Similar to what Image LOCATE=osm will create, but copied to the clipboard rather than launched in a browser.

ClipCopy TARGET

Copies the target of all selected items. One line per item. Useful for .url and .lnk files.

ClipCopy TARGETPATH

Like TARGET, but copies only the path part of the target.

ClipCopy WANIP

Copies the system's public IP address.

NOLOG

Append to suppress logging in the log panel

How to setup and use

:one: Save CommandClipCopy.js.txt to

%appdata%\GPSoftware\Directory Opus\Script AddIns

:two: Copy this menu to a toolbar or create your own buttons with ClipCopy.

Menu as XML
<?xml version="1.0"?>
<button backcol="none" display="both" dropdown_glyph="yes" label_pos="right" textcol="none" type="menu">
	<label>ClipCopy</label>
	<icon1>#clipcopy</icon1>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Columns</label>
		<tip>Copies the current column setup</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy COLUMNS</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Description</label>
		<tip>Copies the description of all selected items</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy DESCRIPTION</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>File as Bitmap</label>
		<tip>Copies the first selected items as a bitmap</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy FILEASBITMAP</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Name and Cloudlink</label>
		<tip>Copies the names and links to cloud storage</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy NAMEANDCLOUDLINK</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Name and Description</label>
		<tip>Copies name and description of all selected items</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy NAMEANDDESCRIPTION</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Name and Product Version</label>
		<tip>Copies name and product version of all selected items</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy NAMEANDPRODVERSION</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Name and Size</label>
		<tip>Copies name and size in bytes of all selected items</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy NAMEANDSIZE</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Name and Size (auto)</label>
		<tip>Copies name and size in bytes (autoformatted) of all selected items</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy NAMEANDSIZEAUTO </instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Name and Target</label>
		<tip>Copies name and target of all selected items</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy NAMEANDTARGET</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>OSM Link</label>
		<tip>Creates http links to OpenStreetmap for all selected images</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy OSMLINK</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Target</label>
		<tip>Copies the target of all selected items</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy TARGET</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Target (path)</label>
		<tip>Copies the target of all selected items (path only)</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy TARGETPATH</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>WAN IP</label>
		<tip>Copies the system&apos;s public IP address</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy WANIP</instruction>
		</function>
	</button>
</button>

:three: Your most wanted stuff is missing? You made an adaptation or something similar that should be included here? Let me know!

Things you might enjoy reading

How to use buttons and scripts from this forum

The script's inner workings

JScript
function OnInit(initData) {
    initData.name = 'ClipCopy';
    initData.version = '2023-06-15';
    initData.url = 'https://resource.dopus.com/t/clipcopy-copy-stuff-to-the-clipboard/44626';
    initData.desc = 'Copy stuff to the clipboard';
    initData.default_enable = true;
    initData.min_version = '12.0';
}

function OnAddCommands(addCmdData) {
    var cmd = addCmdData.AddCommand();
    cmd.name = 'ClipCopy';
    cmd.method = 'OnClipCopy';
    cmd.template = '' +
        'columns/s,' +
        'description/s,' +
        'fileasbitmap/s,' +
        'nameandcloudlink/s,' +
        'nameanddescription/s,' +
        'nameandprodversion/s,' +
        'nameandsize/s,' +
        'nameandsizeauto/s,' +
        'nameandtarget/s,' +
        'nolog/s,' +
        'osmlink/s,' +
        'target/s,' +
        'targetpath/s,' +
        'wanip/s';

    cmd.hide = false;
    cmd.icon = 'script';
}

function OnClipCopy(scriptCmdData) {
    var cmd = scriptCmdData.func.command;
    var tab = scriptCmdData.func.sourcetab;
    var args = scriptCmdData.func.args;

    cmd.deselect = false;

    var tmp = '';

    if (false);
    else if (args.columns) CopyColumns();
    else if (args.description) CopyDescription();
    else if (args.fileasbitmap) CopyFileAsBitmap();
    else if (args.nameandcloudlink) CopyNameAndCloudlink();
    else if (args.nameanddescription) CopyNameAndDescription();
    else if (args.nameandprodversion) CopyNameAndProdversion();
    else if (args.nameandsize) CopyNameAndSize();
    else if (args.nameandsizeauto) CopyNameAndSizeAuto();
    else if (args.nameandtarget) CopyNameAndTarget();
    else if (args.osmlink) CopyOsmLink();
    else if (args.target) CopyTarget();
    else if (args.targetpath) CopyTargetPath();
    else if (args.wanip) CopyWanIp();

    if (tmp == '')
        tmp = '<<< Clipboard has not been changed >>>';
    else {
        DOpus.SetClip(tmp);
    }

    Log(tmp);

    // ====

    function CopyColumns() {
        for (var e = new Enumerator(tab.format.columns); !e.atEnd(); e.moveNext()) {
            if (tmp != '') tmp += '\r\n';
            tmp += 'Set COLUMNSTOGGLE="' + e.item().name + '(!,a,0)"';
        }
    }

    function CopyDescription() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (item.metadata == 'none') continue;
            if (tmp != '') tmp += '\r\n';
            tmp += item.metadata.other.autodesc;
        }
    }

    function CopyFileAsBitmap() {
        if (tab.selected.count == 0) return;
        var item = tab.selected(0);
        cmd.RunCommand('Show FILE="' + item + '" NOUSEEXISTING');
        var newVwrs = cmd.results.newviewers;
        newVwrs(0).Command('selectall');
        newVwrs(0).Command('copy');
        newVwrs(0).Command('close');
    }

    function CopyNameAndCloudlink() {
        DOpus.Output('Enumerating...');
        DOpus.Output('');

        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            DOpus.Output(item);
            tmp += item.name + '\r\n';
            var linkFound = false;

            GetCloudLink('VERB="{3340B3D7-438C-4FC9-81BF-8D9D81B05730}"'); //      Dropbox
            GetCloudLink('VERB="{5250E46F-BB09-D602-5891-F476DC89B702}"'); //      OneDrive
            GetCloudLink('VERB="GetMEGALink"'); //                                 Mega

            // Pick the language that fits your system
            GetCloudLink('LABEL="Copy link to clipboard"'); //                     Google Drive
            // GetCloudLink('LABEL="Copia link negli appunti"'); //                   Google Drive
            // GetCloudLink('LABEL="Copiar enlace en el portapapeles"'); //           Google Drive
            // GetCloudLink('LABEL="Copier le lien dans le presse-papiers"'); //      Google Drive
            // GetCloudLink('LABEL="Link in die Zwischenablage kopieren"'); //        Google Drive

            if (!linkFound) tmp += 'No cloud link found\r\n';
            tmp += '\r\n';
        }

        DOpus.Output('');
        DOpus.Output('... done!');
        DOpus.Output('');

        function GetCloudLink(menuCommand) {
            DOpus.SetClip();
            cmd.RunCommand('ContextMenu ITEMMODE FILE="' + item + '" ' + menuCommand);
            for (var i = 0; i < 20; i++) {
                DOpus.Delay(100);
                var clipText = DOpus.GetClip();
                if (clipText == '') continue;
                tmp += clipText + '\r\n';
                linkFound = true;
                break;
            }
            DOpus.Output(((clipText == '') ? '*** none' : clipText) + ' (Number of wait loops: ' + i + ')');
        }
    }

    function CopyNameAndDescription() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (item.metadata == 'none') continue;
            if (tmp != '') tmp += '\r\n';
            tmp += item.name + '\t' + item.metadata.other.autodesc;
        }
    }

    function CopyNameAndProdversion() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (item.metadata == 'none') continue;
            if (tmp != '') tmp += '\r\n';
            tmp += item.name + '\t' + item.metadata.exe.prodversion;
        }
    }

    function CopyNameAndSize() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (tmp != '') tmp += '\r\n';
            tmp += item.name + '\t' + item.size;
        }
    }

    function CopyNameAndSizeAuto() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (tmp != '') tmp += '\r\n';
            tmp += item.name + '\t' + item.size.fmt;
        }
    }

    function CopyNameAndTarget() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (item.metadata == 'none') continue;
            if (tmp != '') tmp += '\r\n';
            tmp += item.name + '\t' + item.metadata.other.target;
        }
    }

    function CopyOsmLink() {
        var zoomlevel = 18;
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (item.metadata == 'none') continue;
            var lat = item.metadata.image.latitude;
            var lon = item.metadata.image.longitude;
            if (typeof lat != 'number') continue;
            if (typeof lon != 'number') continue;
            if (tmp != '') tmp += '\r\n';
            tmp += 'https://www.openstreetmap.org/?' + '&mlat=' + lat + '&mlon=' + lon + '#map=' + zoomlevel + '/' + lat + '/' + lon;
        }
    }

    function CopyTarget() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (item.metadata == 'none') continue;
            if (tmp != '') tmp += '\r\n';
            tmp += item.metadata.other.target;
        }
    }

    function CopyTargetPath() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (item.metadata == 'none') continue;
            if (tmp != '') tmp += '\r\n';
            tmp += item.metadata.other.target.pathpart;
        }
    }

    function CopyWanIp() {
        var xhr = new ActiveXObject('Microsoft.XMLHTTP');
        var urlIpCheck = 'http://checkip.amazonaws.com';

        xhr.open('GET', urlIpCheck, false);
        xhr.send();

        tmp = xhr.status == 200 ? xhr.responseText.replace(/[^.0-9]/g, '') : 'HTTP STATUS: ' + xhr.status;
    }

    function Log(str) {
        if (args.nolog) return;
        cmd.RunCommand('Set UTILITY=otherlog');
        // DOpus.ClearOutput();
        DOpus.Output('\n' + str);
    }
}
8 Likes

Cool. Can you add a MEGA cloud support, please? and may be some changes to output size format? auto KB, MB??

Try adding this as line 103:

            GetCloudLink('Get MEGA link'); //          Mega

For which command? ClipCopy NAMEANDSIZE?

Yes

it's an item in drop down menu. must be changed according to MEGA's language
thank you

Update 2023-06-14

  • Added support for Mega cloud storage.
  • Added ClipCopy NAMEANDSIZEAUTO which autoformats the size (KB, MB, GB).
2 Likes

thanx
u're forgot to change CommandClipCopy.js.txt - there's an old version))

Oops :blush:

(As they always say... don't post and talk...)

Could you please add a command for the target path (TARGET, but without file name)?

Update 2023-06-15

  • Added ClipCopy TARGETPATH which copies only the path part of the target.
1 Like

Thanks a lot.
Using Settings > File Types, I've added this as a context menu entry.

It's such a gread addin! I'm sure I will use several of its commands in the future.

I'm curious... Would it be possible to have command that leads to a different result depending on the selected object? Eg. Copying the target path when a lnk is selected, but when a different file is selected, copying the folder path instead. Note that I'm not requesting this (I don't need this in my workflow), I'm just curious if it would be possible. :thinking:

Absolutely. No limits :slight_smile:

1 Like