1

Applescript を使用してワイヤレス キーボードを切断しようとしています。

UIブラウザでこのスクリプトを思いつきました:

activate application "SystemUIServer"
tell application "System Events"
tell application process "SystemUIServer"
    click menu item "Disconnect" of menu 1 of menu item "Apple Wireless Keyboard of menu 1 of menu bar item 2 of menu bar 1
end tell
end tell

ただし、次のエラーが発生します。

"System Events got an error: Can’t get menu 1 of menu bar item 2 of menu bar 1 of application process "SystemUIServer". Invalid index."

ここで何が間違っていましたか、どうすれば修正できますか?

4

1 に答える 1

0

これはうまくいくはずです。正しいメニューバー項目が選択されていることを確認してください

tell application "System Events"
    tell application process "SystemUIServer"
        tell menu bar item 2 of menu bar 1
            click
            tell menu item "Apple Wireless Mouse" of front menu
                click
                tell first menu item of front menu
                    click
                end tell
            end tell
        end tell
    end tell
end tell
于 2011-10-13T03:07:33.333 に答える