Copy link to clipboard
Copied
I am trying to write a script that coping the current page as an image to the clipboard.
My approach is to export the current page as a PNG image, and copy it with `nircmd clipboard copyimage` shell command.
I tried using `app.doScript` to run `nircmd`, but without success.
Note: Although I succeeded to do it with a bridge to photoshop:
var bt = new BridgeTalk();
bt.target = "photoshop";
bt.body = "var f = File('" + tempFile.fsName + "');" +
"app.open(f);" +
"app.activeDocument.selection.selectAll();" +
"app.activeDocument.selection.copy();" +
"app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);" +
"app.close(f);" +
"f.remove();";
bt.send();
but it opens the photoshop program, and it's annoying.
Copy link to clipboard
Copied
Why do you need to have it in the clipboard?
What is your end goal?
Copy link to clipboard
Copied
I want to paste the image outside of Indesign, like in WhatsApp, and send it to the customer.
Copy link to clipboard
Copied
As @Dirk Becker suggested - doing it in the "native" scripting language - AppleScript on a Mac - VisualBasic on a PC - would be much easier.
Copy link to clipboard
Copied
Hi @yoav_4837 I have no experience with this specifically, but I wondered if it would work to re-import the image (particular formats might be better than others?) into Indesign and select/copy it via indesign (I mean copy the placed image, not the graphic frame, or try both). The question is, what exactly does it put on the clipboard and is it paste-able in other apps? Just wondering if you've tried it.
- Mark
Copy link to clipboard
Copied
Yes, I have tried.
When I copy an Image from Indesign, it's available (as an image) only in the clipboard of the program. Outside it behaves like an empty clipboard.
Copy link to clipboard
Copied
InDesign keeps an own clipboard "scrap".
Clipboard externalization is a costly process, similar to an export multiplied by the number of supported flavours.
Not sure what triggers externalization, as your switching to WhatsApp (deactivating InDesign) apparently did not.
Or did you forget to activate WhatsApp?
Alternatively, ask the search engine or AI of your choice for a program in the environment of your choice (VBScript? Powershell?) to load the exported png file into the Windows clipboard.
When I did, the vbscript would use the user32 dll with commands such as OpenClipboard, while the Powershell script would rely on ImageMagick. I did not test either, typing this on a Mac.
For comparison, the Mac clipboard is directly scriptable.
Copy link to clipboard
Copied
I tried with claude.ai, and the code I received doesn't compile.