Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Copy image to clipboard

New Here ,
Jan 18, 2025 Jan 18, 2025

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.

TOPICS
How to , Scripting
542
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 18, 2025 Jan 18, 2025

Why do you need to have it in the clipboard? 

 

What is your end goal? 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 18, 2025 Jan 18, 2025

I want to paste the image outside of Indesign, like in WhatsApp, and send it to the customer. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 19, 2025 Jan 19, 2025

@yoav_4837

 

As @Dirk Becker suggested - doing it in the "native" scripting language - AppleScript on a Mac - VisualBasic on a PC - would be much easier.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 18, 2025 Jan 18, 2025

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 18, 2025 Jan 18, 2025

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jan 19, 2025 Jan 19, 2025

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 19, 2025 Jan 19, 2025
LATEST

I tried with claude.ai, and the code I received doesn't compile.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines