我正试图用AE扩展脚本将AE中的一些文本复制到系统剪贴板。After Effects在Extendscript中没有直接提供此功能。
我可以将文本放在文本层上,然后用将其复制到剪贴板
app.executeCommand(app.findMenuCommandId("Copy"));
但要做到这一点,必须选择文本。可以使用
app.executeCommand(app.findMenuCommandId("Select All"));
但是,光标必须在字段中才能工作。
我正在尝试使用After Effects中的Extendscript将光标放置在文本层文本字段中。我无论如何都看不到要那样做。
我已经使用.bat方法将变量的值复制到系统剪贴板,但这并不能在所有系统上都起作用。最好的方法是真正留在AE内部。
有人知道如何在AE Extendscript中控制文本光标吗?
有什么想法吗?
使用vbs脚本和sendkeys
怎么样?您可以创建脚本来执行sendkeys的操作(因为您不能在javascript中执行),然后使javascript文件在适当的位置调用vbs脚本。
以下是Extendescript中的工作原理:
//This works on Vista and Win 7, XP requires the user to copy 'clip.exe' to the 'sys32' folder.
function copyTextToClipboard2(text)
{
var folderForTempFiles = Folder.temp.fsName;
//alert(folderForTempFiles)
// 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("clip < " + folderForTempFiles + "/ClipBoard.txt");
clipBatFile.close();
clipBatFile.execute();
}
有人做过类似苹果的东西吗?
我已经在After Effects CC的mac上测试过了,它运行良好:
text = 'Lets copy some 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();
system.callSystem("cat " + folderForTempFiles + "/ClipBoard.txt" + " | pbcopy");