Lar*_*son 5 photoshop clipboard copy jsx
现在我使用prompt命令作为解决方法,从Photoshop中的JSX脚本中复制任意文本.
prompt("to copy",(horizontalcenter.toString()) + ", " + verticalcenter.toString());
Run Code Online (Sandbox Code Playgroud)
那就是给我我想要的信息."复制"只是给出了标题,然后我要复制出Photoshop的信息就在已经选中的提示框中.所以我要做的就是点击控制C,转到Notepad ++,我需要这些信息,并点击控制V.
它有效,但它可能更快.必须有一种方法将这些信息直接从Photoshop复制到剪贴板,不是吗?
Photoshop 13.1(Photoshop CS6的最新Creative Cloud版本)现在有一个钩子,允许您直接执行此操作.这是一个示例函数:
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 );
}
Run Code Online (Sandbox Code Playgroud)
请注意,这不适用于13.1之前的Photoshop版本
在Photoshop脚本论坛上找到了答案。
function copyTextToClipboard(text)
{
var folderForTempFiles = Folder.temp.fsName;
// create a new textfile and put the text into it
var clipTxtFile =new File(folderForTempFiles + "/ClipBoard.txt");
clipTxtFile.open('w');
clipTxtFile.write(text);
clipTxtFile.close();
// use the clip.exe to copy the contents of the textfile to the windows clipboard
var clipBatFile =new File(folderForTempFiles + "/ClipBoard.bat");
clipBatFile.open('w');
clipBatFile.writeln("cat \"" + folderForTempFiles + "/ClipBoard.txt\"|clip");
clipBatFile.close();
clipBatFile.execute();
}
Run Code Online (Sandbox Code Playgroud)
它将要复制的文本放在临时文本文件中,然后从该文本文件中复制它。我什至不知道您可以将文本放入文本文件中。显然,Photoshop中的javascript功能比我意识到的要强大得多!
| 归档时间: |
|
| 查看次数: |
4689 次 |
| 最近记录: |