AppleScript从列表中选择

时间:2015-05-21 11:29:23

标签: dialog applescript

非常简单的问题,但如何从"从List"

中选择启动脚本

例如:

set issueList to {"1", "2", "2", "4"}

set selectedIssue to {choose from list issueList}

if selectedIssue is {"1"} then
    display dialog "ok" buttons {"1"} default button 1
else if selectedIssue is {"Holds Charge"} then
    -- do nothing
    display dialog "ok" buttons {"2"} default button 1
else if selectedIssue is {"2"} then
    -- do nothing
    display dialog "ok" buttons {"3"} default button 1
else if selectedIssue is {"3"} then
    -- do nothing   
    display dialog "ok" buttons {"4"} default button 1
end if

当我点击列表中的元素,通知开始(或任何其他脚本)时,我在此脚本中的预期,但我没有结果。

干杯

2 个答案:

答案 0 :(得分:2)

通知会返回{{" 1"}},而非{" 1"}。将您的代码更改为

if item 1 of selectedIssue is {"1"} then
等等,它应该工作。

答案 1 :(得分:0)

你好,我也遇到了同样的问题,但是我用这样的代码解决了:

set mailList to {"One","Two","Three","Four"}
set mailType to choose from list mailList

if item 1 of mailType is "One" then
    display dialog mailType 
else if item 1 of mailType is "Two" then
    display dialog mailType 
else if item 1 of mailType is "Three" then
    display dialog mailType 
else if item 1 of mailType is "Four" then
    display dialog mailType 
end if