每次脚本 运行 时都没有正确设置 AppleScript 剪贴板

AppleScript clipboard isn't being properly set each time the script is run

我有一个 AppleScript I am 运行ning 将当前剪贴板保存到一个临时变量,将剪贴板设置为其他内容(在本例中为表情符号),将剪贴板粘贴到一个字段中,然后将剪贴板还原为脚本 运行.

之前的状态
set temp to the clipboard
set the clipboard to ""
tell application "System Events"
    keystroke "v" using command down
end tell
set the clipboard to temp

它在第一次 运行 时工作正常,但如果它 运行 两次或更多次,它会第一次粘贴表情符号,然后每隔一次粘贴原始剪贴板。

我可以通过添加延迟来解决我这边的问题...

set temp to the clipboard
set the clipboard to ""
tell application "System Events"
    keystroke "v" using command down
    delay 0.3
end tell
set the clipboard to temp