2011-04-14 3 views
0

AppleScript가 처음입니다. 나는 약간의 검색 및 읽기를 수행하고 메뉴 항목을 활성화하기위한 작업을하도록되어 뭔가를 발견했습니다AppleScript에서 Seamonkey의 메뉴 항목을 활성화하려고합니다.

tell application "SeaMonkey" 
    activate 
end tell 
tell application "System Events" 
    click menu item "Composer" of menu "Windows" of menu bar item "Windows" of menu bar 1 of process "SeaMonkey" 
     --> error number -1728 from «class mbri» "Windows" of «class mbar» 1 of «class prcs» "SeaMonkey" 
end tell 

결과 : 거짓 나는 이벤트 로그 창에 표시되는지 실행하면

on do_menu(app_name, menu_name, menu_item) 
    try 
     -- bring the target application to the front 
     tell application app_name 
      activate 
     end tell 
     tell application "System Events" 
      tell process app_name 
       tell menu bar 1 
        tell menu bar item menu_name 
         tell menu menu_name 
          click menu item menu_item 
         end tell 
        end tell 
       end tell 
      end tell 
     end tell 
     return true 
    on error error_message 
     return false 
    end try 
end do_menu 

-- In my case I want to start Seamonkey and open the Composer window (and select it) so I 
-- do: 
do_menu("SeaMonkey", "Windows", "Composer") 

내가 뭘 잘못하고 있는지 알지 못합니다.

답변

1

오류 코드 -1728은 AppleScript에서 일반적인 "찾을 수 없음"오류 인 것 같습니다. 나는 Windows 메뉴를 SeaMonkey에 표시하지 않지만, 메뉴를 볼 수 있습니다. "s"를 Windows에서 삭제하십시오.

또한 '클릭'이 작동하도록 '보조 장치 용 액세스'를 사용해야 할 수도 있다고 생각합니다. 필요할 경우 해당 오류 메시지가 표시됩니다.

0

@mu가 너무 짧습니다. 'Windows'에서 's'을 제거하면 제대로 작동합니다. 비록 핸들러 사용을 다루고 싶지 않다면 압축 된 버전이 있습니다.

activate application "SeaMonkey" 
tell application "System Events" 
    tell process "SeaMonkey" 
     click menu item "Composer" of menu 1 of menu bar item "Window" of menu bar 1 
    end tell 
end tell 
관련 문제