如果与列表一起使用时函数在 AppleScript 中不起作用

If functions not working in AppleScript when used with lists

我正在尝试形成一个脚本,根据我所学的科目开设不同的教室,但没有成功。

这是我用过的脚本。

set theList to {"Maths", "Further Maths", "Physics", "Chemistry"}
set lesson to choose from list theList with prompt "What lesson do you have?"
if lesson is equal to "Further Maths" then
do shell script "open https://classroom.google.com/u/0/c/A"
end if

以此类推类。

choose from list returns 总是一个列表(或者 false 如果用户按下取消按钮),即使没有指定 with multiple selections allowed

单选模式下你必须得到列表的第一项

set theList to {"Maths", "Further Maths", "Physics", "Chemistry"}
set lesson to choose from list theList with prompt "What lesson do you have?"
if lesson is false then return
if (item 1 of lesson) is equal to "Further Maths" then
    do shell script "open https://classroom.google.com/u/0/c/A"
end if