Photoshop JSX - 如何将任意文本到剪贴板? [英] Photoshop JSX -- How do I copy arbitrary text to the clipboard?

查看:418
本文介绍了Photoshop JSX - 如何将任意文本到剪贴板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我使用prompt命令作为一种解决方法,在Photoshop中从我的JSX脚本中复制任意文本。

 提示(要复制,(horizo​​ntalcenter.toString())+,+ verticalcenter.toString()); 

这就是给我的信息。 复制只是给出标题,然后我想从Photoshop复制的信息是在已经选择的提示框中。所以我需要做的是命中控制C,去记事本++,我需要这个信息,并击中控制V。



它的工作,但它可以更快。有没有办法将这些信息从Photoshop直接复制到剪贴板?

解决方案

Photoshop 13.1 Creative Cloud发布的Photoshop CS6)现在有一个钩子,你可以直接这样做。这里有一个示例函数:

  function copyTextToClipboard(txt)
{
const keyTextData = app.charIDToTypeID 'TxtD');
const ktextToClipboardStr = app.stringIDToTypeID(textToClipboard);

var textStrDesc = new ActionDescriptor();

textStrDesc.putString(keyTextData,txt);
executeAction(ktextToClipboardStr,textStrDesc,DialogModes.NO);
}

请注意,这不适用于Photoshop 13.1之前的版本


Right now I am using the prompt command as a workaround to copy arbitrary text out of my JSX script in Photoshop.

prompt("to copy",(horizontalcenter.toString()) + ", " + verticalcenter.toString());

And that is giving me the information that I want. The "to copy" just gives the title, then the information I want to copy out of Photoshop is in the prompt box already selected. So all I have to do is hit control C, go to Notepad++ where I need this information, and hit control V.

It works, but it could be faster. There has to be a way to copy this information out of Photoshop straight to the clipboard, no?

解决方案

Photoshop 13.1 (the latest Creative Cloud release of Photoshop CS6) now has a hook allowing you to do this directly. Here's a sample function:

function copyTextToClipboard( txt )
{
    const keyTextData         = app.charIDToTypeID('TxtD');
    const ktextToClipboardStr = app.stringIDToTypeID( "textToClipboard" );

    var textStrDesc = new ActionDescriptor();

    textStrDesc.putString( keyTextData, txt );
    executeAction( ktextToClipboardStr, textStrDesc, DialogModes.NO );
}

Please note this won't work in versions of Photoshop prior to 13.1

这篇关于Photoshop JSX - 如何将任意文本到剪贴板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆