我可以获得一个主菜单项,并且我已经能够使用系统事件来选择并单击窗口中的特定按钮。我遇到了一个问题,我想获取属于弹出“工作表”的按钮的“句柄”。例如,iTunes 中的“airplay”按钮:
我可以使用类似于以下内容的按钮来单击以打开工作表:
click button 10 of window "iTunes" of application process "iTunes" of application "System Events"
我可以key code
用来手动上下滚动,尽管我正在寻找一种最有效和最优雅的选择我想要的特定按钮的解决方案(在这种情况下,名称为“计算机”)
我正在使用辅助功能检查器,并且可以获得有关菜单的一些信息:
<AXApplication: “iTunes”>
<AXWindow: “iTunes”>
<AXMenu>
<AXMenuItem: “AirPort Express”>
Attributes:
AXRole: “AXMenuItem”
AXRoleDescription: “menu item”
AXParent: “<AXMenu>”
AXEnabled: “1”
AXPosition: “x=1070 y=798”
AXSize: “w=146 h=22”
AXTitle: “AirPort Express”
AXHelp: “(null)”
AXSelected (W): “1”
AXMenuItemCmdChar: “(null)”
AXMenuItemCmdVirtualKey: “(null)”
AXMenuItemCmdGlyph: “(null)”
AXMenuItemCmdModifiers: “0”
AXMenuItemMarkChar: “(null)”
AXMenuItemPrimaryUIElement: “(null)”
Actions:
AXCancel - cancel
AXPress - press
那么这些弹出窗口有特定的标题吗?喜欢select button 1 of sheet 1 of...
我认为这可能很容易,我在考虑这个问题。
干杯!博
我尝试了什么:
--click menu item "Computer" of menu 1 of window "iTunes" of application process "iTunes"
--tell application "System Events" to tell process "iTunes"
-- tell menu 1 of menu bar item 1 of menu bar 2
-- click menu item "Copy"
-- end tell
--end tell
--click (every button whose value of attribute "AXTitle" is "Computer") of window "iTunes" of application process "iTunes"
--tell window 1
--click button "Computer" of tool bar 1 of window "iTunes" of application process "iTunes"
-- click button 1 of group 1 of group 1 of window "iTunes" of application process "iTunes"
--end tell
click (menu item 2 of every menu item whose attribute "AXRoleDescription" is "menu item") of window "iTunes" of application process "iTunes"
--click (button whose description is "menu item") of window "iTunes" of application process "iTunes"