User interface 在AppleScript中选择弹出菜单按钮
我想自动单击特定的弹出菜单项。 例如,我想将“Message receive Sound”的值更改为其他值。如何使用AppleScript执行此操作?我如何使用AppleScript中的其他弹出菜单来实现这一点 (要打开如图所示的iMessage设置菜单,请在打开iMessage后键入CMD逗号) 注意:我已经成功地完成了这个自动机,我只想在applescript中完成它User interface 在AppleScript中选择弹出菜单按钮,user-interface,applescript,imessage,User Interface,Applescript,Imessage,我想自动单击特定的弹出菜单项。 例如,我想将“Message receive Sound”的值更改为其他值。如何使用AppleScript执行此操作?我如何使用AppleScript中的其他弹出菜单来实现这一点 (要打开如图所示的iMessage设置菜单,请在打开iMessage后键入CMD逗号) 注意:我已经成功地完成了这个自动机,我只想在applescript中完成它 它被称为GUI脚本。您必须标识对UI元素的引用 GUI脚本很大程度上取决于系统版本。如果更新更改了UI结构,脚本将停止 这将
它被称为GUI脚本。您必须标识对UI元素的引用 GUI脚本很大程度上取决于系统版本。如果更新更改了UI结构,脚本将停止 这将在声音弹出菜单中选择声音“爆米花”。是给El Capitan的。在<10.11的系统中,UI元素可能不同,流程名称可能为“iChat”
如何确定菜单/按钮/组号?使用或苹果的
tell application "System Events"
tell process "Messages"
set frontmost to true
if not (exists (1st window whose value of attribute "AXIdentifier" is "MessagesPreferencesWindow")) then
keystroke "," using command down
repeat until exists (1st window whose value of attribute "AXIdentifier" is "MessagesPreferencesWindow")
delay 0.1
end repeat
end if
tell (1st window whose value of attribute "AXIdentifier" is "MessagesPreferencesWindow")
tell pop up button 4 of group 1
click
delay 0.2
click menu item "Popcorn" of menu 1
end tell
end tell
end tell
end tell