【问题标题】:Applescript if contains a wordApplescript 如果包含一个单词
【发布时间】:2016-12-14 11:34:13
【问题描述】:

这是我的脚本:

set APPS to { "facebook", "Minecraft"}
if appName contains APPS then
    display notification "app founds" with title "Apps"

我也试试

if appName is in APPS then

但在本例中,如果找到的应用程序是“我的世界:故事模式”,那么脚本将失败(不会检测到任何内容)我怎样才能让脚本检测到呢?

亲切的问候

【问题讨论】:

    标签: if-statement applescript contain


    【解决方案1】:

    如果要检查集合中的项目是否包含子字符串,则需要重复循环

    set APPS to {"facebook", "Minecraft"}
    repeat with anApp in APPS
        if appName is in anApp then -- or anApp is in appName depending on which is the substring
            display notification "app founds" with title anApp
            exit repeat
        end if
    end repeat
    

    【讨论】:

    • 谢谢,问题是如果找到的变量是“我的世界:故事模式”,那将不起作用,或者我应该写下所有可以修复它的变量
    猜你喜欢
    • 2017-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-28
    • 1970-01-01
    • 1970-01-01
    • 2016-03-21
    • 1970-01-01
    相关资源
    最近更新 更多