在AppleScript中设置剪贴板的内容

时间:2012-06-12 21:22:41

标签: applescript clipboard

我想将剪贴板的内容设置为变量。我以前做过这个,它应该很简单,但我收到了一个错误。

on checkiPadFinished()
    set tempiPadSerial to "b"
    tell application "System Events"
        tell process "iTunes"
            keystroke "c" using {command down}
            set tempiPadSerial to the clipboard as string
            if firstiPadSerial is tempiPadSerial then
                return true
            else if firstiPadSerial is "a" then
                set firstiPadSerial to the clipboard as string
            end if
        end tell
    end tell
    return false
end checkiPadFinished

在我的代码中,我声明了全局变量

全球XXX,yyy,zzz,firstiPadSerial 将firstiPadSerial设置为“a”

对checkiPadFinished()的调用如下:

set doneiPads to my checkiPadFinished()

据我所知,一切都应该有效,但我得到的是一个神秘的错误信息。

编辑:没有改变它正在运行的任何东西。我不知所措。我希望我写下错误信息。但是我第10次按下了go按钮并且它有效,所以我甚至无法说出消息是什么。

1 个答案:

答案 0 :(得分:1)

尝试:

  activate application "iTunes"
tell application "System Events"
    tell process "iTunes"
        select row 15 of outline 1 of scroll area 2 of window "iTunes"
        keystroke "c" using {command down}
        delay 0.5 -- jackjr300's suggestion
        set xxx to the clipboard
    end tell
end tell

enter image description here