首页 > 解决方案 > Apple Script 从代码块中获取结果值

问题描述

我有一段代码返回输入语言的当前值

tell process "SystemUIServer" to 
   get the value of the first menu bar item of menu bar 1 
   whose description is "text input"
tell end

现在我想检查结果,IF Else但我不知道该怎么做!

谢谢

标签: macosapplescript

解决方案


首先,你必须告诉System Events做这项工作。

只需将结果分配给变量

activate application "SystemUIServer"
tell application "System Events"
    tell process "SystemUIServer"
        set textInput to (get value of the first menu bar item of menu bar 1 whose description is "text input")
    end tell
end tell

推荐阅读