【问题标题】:get iTunes player state in AppleScript在 AppleScript 中获取 iTunes 播放器状态
【发布时间】:2015-06-28 16:41:52
【问题描述】:

我有这个问题: 在脚本编辑器中运行此脚本时,它可以完美运行。

tell application "iTunes"
set playerstate to get player state
end tell
display dialog playerstate

我得到了玩家状态runningstoppedpaused。 但如果我将脚本导出为应用程序,我会得到类似kPSS 的信息。

错在哪里?

【问题讨论】:

    标签: applescript


    【解决方案1】:

    player state 是一个枚举常量(实际上是一个整数)。 只需将值强制为文本

    tell application "iTunes"
        set playerstate to (get player state) as text
    end tell
    display dialog player state
    

    编辑:

    这也适用于小程序

       tell application "iTunes"
            if player state is paused then
                set playerStateText to "Paused"
            else if player state is playing then
                set playerStateText to "Playing"
            else
                set playerStateText to "Stopped"
            end if
        end tell
        display dialog playerStateText
    

    【讨论】:

    • 我不工作,你的脚本结果是«constant ****kPSS»
    猜你喜欢
    • 2023-03-08
    • 2014-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    • 2012-01-28
    • 1970-01-01
    相关资源
    最近更新 更多