我有这个问题: 在Script-Editor中运行此脚本时,它可以很好地工作。
tell application "iTunes"
set playerstate to get player state
end tell
display dialog playerstate
我获得了播放器状态running
,stopped
或paused
。
但是,如果我将脚本导出为应用程序,我会得到类似kPSS
的内容。
错误在哪里?
答案 0 :(得分:3)
player state
是枚举常量(实际上是整数)。
只需将值强制转换为文本
tell application "iTunes"
set playerstate to (get player state) as text
end tell
display dialog player state
修改强>
这也适用于applet
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