[solved] Paste script mouse click

Hello,

I will be very grateful if you can help me with this. I am working in a script (copyPaste.js) and i am blocked in one point. I need to simulate a mouse click on anyplace of my document, after copy and paste. It works correctly but i need to say where my object must been paste.

At the moment, my code is the follows:

//Begin.
var action = RGuiAction.getByScriptFile(“scripts/Edit/Copy/Copy.js”);
if (!isNull(action)) {
action.slotTrigger();
}

var action = RGuiAction.getByScriptFile(“scripts/File/NewFile/NewFile.js”);
if (!isNull(action)) {
action.slotTrigger();
}
var document = getDocument();


var action = RGuiAction.getByScriptFile(“scripts/Edit/Paste/Paste.js”);
if (!isNull(action)) {
action.slotTrigger();
}

//MOUSE_CLICK

this.autoZoom();
//End.


I need to put the code on //MOUSE_CLICK zone.

Many thanks!!
Kind regards.

This won’t work as Paste is an interactive tool requiring the target position as user input as well as other parameters.

FileNew and Copy are not interactive and immediately return control to your script.

To paste the clipboard, you can use a paste operation as follows (where x and y are your target coordinates):

var op = new RPasteOperation(RDocument.getClipboard());
op.setOffset(new RVector(x,y));
op.setRotation(0.0);
op.setScale(1.0);
op.setFlipHorizontal(false);
op.setFlipVertical(false);
op.setToCurrentLayer(true);
op.setOverwriteBlocks(true);
op.setCopyEmptyBlocks(true);

var di = getDocumentInterface();
di.applyOperation(op);

It works!!.

Many many thanks.
I’m really grateful