Zad*_*ade 5 applescript paste text-formatting
我以为这会很简单...
我想要一个启动普通剪辑的 AppleScript,然后将剪贴板粘贴到光标所在的当前文档中。我的脚本启动Plain Clip(一种不会窃取焦点的格式清除应用程序),但它不会粘贴新的剪贴板。有任何想法吗?
tell application "Plain Clip" to activate
delay 1
tell application "System Events" to tell (name of application processes whose frontmost is true) to keystroke "v" using {command down}
Run Code Online (Sandbox Code Playgroud)
小智 3
由于无论如何您都将剪贴板剥离为纯文本,因此您也许可以通过编写键盘脚本而不是编写纯剪辑脚本来完成。
do shell script "pbpaste |textutil -convert txt -stdin -stdout -encoding 30 |pbcopy"
tell application "System Events" to keystroke (the clipboard)
Run Code Online (Sandbox Code Playgroud)
ps 第一行的作用与 Plain Clip 的作用相同。
pps 脚本系统事件需要访问辅助设备才能打开。