Applescript - 使用“从列表中选择”时变量命令不起作用

时间:2012-10-30 18:51:04

标签: applescript

我正在尝试为iTunes创建一个简单的国际商店。

set country to (choose from list {"US", "CA", "UK"} with prompt "What country?")

   if country = "US" then
     tell application "iTunes"
     activate   
     open location "itmss://itunes.apple.com/WebObjects/MZStore.woa/wa/switchToStoreFront?storeFrontId=143441"
end tell
end if

当我点击美国时,它对iTunes没有任何作用。我做错了什么?

2 个答案:

答案 0 :(得分:1)

问题是choose from list命令正在返回从列表中选择的项目列表。您可以执行以下操作:

set country to (choose from list {"US", "CA", "UK"} with prompt "What country?")

if country = {"US"} then
    tell application "iTunes"
        activate
        open location "itmss://itunes.apple.com/WebObjects/MZStore.woa/wa/switchToStoreFront?storeFrontId=143441"
    end tell
end if

或者,您可以说if item 1 of country = "US"

答案 1 :(得分:0)

尝试

if country as text = "US" then