【问题标题】:Applescript Paste and Tab From a Comma Delimited ListApplescript 从逗号分隔列表粘贴和制表符
【发布时间】:2015-11-25 22:52:28
【问题描述】:

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

它似乎不想粘贴到谷歌浏览器的文本字段中。

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

【问题讨论】:

  • 您好,请不要在您的问题中发布有效的解决方案,如果该解决方案与 pbell 答案不同,请使用该内容自己编写另一个答案。否则,将答案标记为已接受并投票即可完成工作:)

标签: macos applescript automator


【解决方案1】:

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

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

【讨论】:

  • 谢谢。对于后代,它适用于“谷歌浏览器”。我已经用一个可行的解决方案更新了这个问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多