2013-04-28 2 views
0

목록에서 선택 대화 상자를 통해 '최근 항목'하위 메뉴에서 선택한 항목을 열려면이 AppleScript를 작성했습니다. 첫 번째 항목에 대해 작동 한 다음 정상적으로 종료하고 다른 항목을 열지 않습니다.최근 문서 하위 메뉴 열기

아래에서 볼 수있는대로 '표시 대화 상자'를 추가하여 제대로 작동하는지 아이디어를 얻을 수 있습니다. 아직도, 그것은 ...하지 않는

tell application "Finder" 
    activate 
    try 
     tell application "System Events" 
      tell process "Finder" 
       tell menu "Recent Items" of menu item "Recent Items" of menu 1 of menu bar 1 
        set menuItemNames to (get name of (every menu item whose position ≠ missing value and name ≠ "Applications" and name ≠ "Documents" and name ≠ "Servers" and name ≠ missing value)) 
        set text item delimiters of AppleScript to "," 
        set targetMenuItems to (choose from list menuItemNames with prompt "Choose a recent document to view:" with title "Recent Documents" OK button name "Open" with multiple selections allowed) as list 
        set targetMenuItems to (text items of targetMenuItems as text) 
        if targetMenuItems ≠ "false" then 
         set menuitemCount to (count text items in targetMenuItems) 
         display dialog menuitemCount 
         display dialog (text item 1 of targetMenuItems) 
         set x to 1 
         repeat menuitemCount times 
          set targetItem to (text item x of targetMenuItems) 
          display dialog targetItem 
          click menu item targetItem 
          set x to x + 1 
         end repeat 
        end if 
       end tell 
      end tell 
     end tell 
    on error errorMsg 
     display dialog errorMsg 
    end try 
end tell 

답변

0

나는 목록을 텍스트로 변환 된 이유를 몇 가지 이유가 누락 될 수 있지만,이 여러 항목으로 작동하는 것 같다가 :

delay 0.3 
tell application "System Events" to tell (process 1 where it is frontmost) 
    tell menu 1 of menu item "Recent Items" of menu 1 of menu bar 1 
     set menuitems to name of (menu items where position is not missing value and name is not "Applications" and name is not "Documents" and name is not "Servers" and name is not "Clear Menu" and name is not missing value) 
     tell application (path to frontmost application as text) 
      activate 
      choose from list menuitems with multiple selections allowed 
     end tell 
     repeat with m in result 
      click menu item m 
     end repeat 
    end tell 
end tell 
+0

이 완벽하게 작동하는 것 같다 당신이 '말하기 응용 프로그램'Finder '를'활성화 '에 추가하는 한 처음에. 도와 줘서 고마워! – AppleScripter