2011-10-13 5 views
1

AppleScript로 내 무선 키보드의 연결을 끊으려고합니다. 내가 잘못 여기에서 않았고, 내가 그것을 어떻게 해결할 수 무엇Apple Script는 화면 상단의 메뉴 막대에서 무선 키보드를 끊습니다.

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

:

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 

그러나, 나는 다음과 같은 오류가 얻을 :

나는 UI 브라우저에서이 스크립트를 내놓았다 ?

+0

이것은 컴파일하지 않아야합니다. '... 메뉴 항목 'Apple Wireless Keyboard (인용 부호 없음)'또는 오타입니까? – fireshadow52

답변

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