逗号分隔列表中的 Applescript 粘贴和制表符

Applescript Paste and Tab From a Comma Delimited List

我正在尝试让一个自动程序 applescript 循环通过一个逗号分隔的列表;并在此过程中粘贴值 1、制表符、粘贴值 2、制表符等...

它似乎不想粘贴到 google chrome 中的文本字段。

display dialog "What is the list? (Artist, Song Title, Artist, Song Title)" default answer "Frank Sinatra, My Way, Elvis, Blue Christmas"
set user_input to text returned of result

set {myTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {","}}
set myList to text items of user_input -- Gives list {"2", "69", "12"}
set AppleScript's text item delimiters to myTID -- It's considered good practice to return the TID's to their original state

repeat with myItem in myList -- Loop through the items in the list
    tell application "System Events"
        set the clipboard to myItem
        keystroke "v" using {command down}
        keystroke tab
    end tell
    delay 1
end repeat

display dialog "Job Done"

return

您的粘贴命令是在您的脚本上完成的,而不是在其他应用程序上完成的(Chrome 在您的情况下)。您必须告诉哪个进程应该接收击键。像 :

tell application "System Events"
tell process "Chrome"
Set the clipboard to myItem
keystroke "v" using {command down}
keystroke tab
end tell
end tell