如何使用AppleScript为变量赋值?
如何将从菜单栏1的第一个菜单栏项(其说明为“文本输入”)获取的值分配给另一个变量如何使用AppleScript为变量赋值?,applescript,Applescript,如何将从菜单栏1的第一个菜单栏项(其说明为“文本输入”)获取的值分配给另一个变量 tell application "System Events" tell process "SystemUIServer" get value of first menu bar item of menu bar 1 whose description is "text input" end tell end tell 将get value of…视为输出,并以常规方式将值分配给
tell application "System Events"
tell process "SystemUIServer"
get value of first menu bar item of menu bar 1 whose description is "text input"
end tell
end tell
将
get value of…
视为输出,并以常规方式将值分配给变量。不要忘记在get value of…(获取值)
tell application "System Events"
tell process "SystemUIServer"
set inputValue to (get value of first menu bar item of menu bar 1 whose description is "text input")
return inputValue
end tell
end tell
通常不需要括号。如果需要,脚本编辑器通常会为您插入它们,这在使用
的过滤器时可能会发生。您还可以在自己的行上使用get…
命令(正如您在发布问题时所做的那样),然后将它后面的行设置结果的inputValue
。哦,我忽略了提到的另一个明显的解决方案是简单地删除单词get
。它通常是多余的,我只能想到一种情况,它有一个特定的用途,那就是当您希望评估一个部分取消引用的项目列表时,例如Finder的选择
。因此,告诉应用程序“Finder”返回所选内容的项目1将抛出一个错误,但是告诉应用程序“Finder”返回(获取所选内容)
的项目1(此处需要括号),将完全取消对选择对象的引用,从而允许检索项目1
。