2

メインメニュー項目を取得でき、システムイベントを使用して、ウィンドウ内の特定のボタンを選択してクリックすることができました。ポップアップシートに属するボタンの「ハンドル」を取得したいという問題が発生しています。たとえば、iTunesの「airplay」ボタン:

この場合、2つのアイテムがあります

次のようなものを使用して、ボタンをクリックしてシートを開くことができます。

click button 10 of window "iTunes" of application process "iTunes" of application "System Events"

key code手動で上下にスクロールすることもできますが、必要な特定のボタンを選択するための最も効率的でエレガントなソリューションを探しています(名前、この場合は「コンピューター」)。

アクセシビリティインスペクタを使用していますが、メニューに関する情報を取得できます。

<AXApplication: “iTunes”&gt;
 <AXWindow: “iTunes”&gt;
  <AXMenu>
   <AXMenuItem: “AirPort Express”&gt;

Attributes:
   AXRole:  “AXMenuItem”
   AXRoleDescription:  “menu item”
   AXParent:  “&lt;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...

これはおそらく簡単だと思います。私はこの問題について考えすぎています。

乾杯!bo

何を試しましたか:

    --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"
4

2 に答える 2

1

カスタマイズされたメニューでは不可能です:<Window "iTunes"> --> <Menu>

ポップアップボタンで可能です。<Window "iTunes"> --> <popup button> --> <Menu>

引き続き使用する必要がありますkey code

于 2012-07-07T22:45:18.203 に答える
0

アクセシビリティインスペクタに表示される階層は、使用する必要があるものです。メニューはポップアップするまで利用できないので、少し待つ必要があるかもしれません-テストする外部スピーカーはありませんが、次のようにします。

tell application "System Events"
    click button 10 of window "iTunes" of application process "iTunes"
    delay 1 -- give menu time to pop up
    click menu item "Computer" of menu 1 of window "iTunes" of application process "iTunes"
end tell

click menu item "Computer" of front menuメニューをポップアップしてから使用できる場合もあります。インデックスが正しくない場合は、通常、メニューをポップアップして階層をさかのぼり、メニューを取得して正しいインデックスを見つけ、メニューのメニュー項目を取得するなどの方法があります。

于 2012-07-08T04:25:50.320 に答える