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 回答