2012-11-12 79 views
7

有沒有什麼辦法可以通過AppleScript獲得菜單標題FileEdit下所有菜單項的列表?如何獲得AppleScript菜單項列表?

我發現了一些相關的問題,但沒有確切的。在Google上也沒有運氣。

我試圖獲得哪些文件在Photoshop的Window菜單中打開的列表,並找出哪一個具有複選標記。

screenshot-with-shadow.png http://img33.imageshack.us/img33/4526/screenshotwithshadow.png

我想我也許可以使用類似「In Applescript, how can I find out if a menu item is selected/focused?」做第二部分和輔助檢查,因爲它有AXMenuItemMarkChar

screenshot-with-shadow.png http://img99.imageshack.us/img99/4526/screenshotwithshadow.png

回答

9

我沒有的Photoshop但這適用於Illustrator:

activate application "Adobe Illustrator" 
tell application "System Events" 
    tell process "Adobe Illustrator CS5.1" 
     set xxx to name of every menu item of menu 1 of menu bar item "Window" of menu bar 1 
    end tell 
end tell 

要得到一個attribu TE可以使用:

activate application "Adobe Illustrator" 
tell application "System Events" 
    tell process "Adobe Illustrator CS5.1" 
     set xxx to value of attribute "AXMenuItemMarkChar" of menu item "tools" of menu 1 of menu bar item "Window" of menu bar 1 
    end tell 
end tell 

零場景:

activate application "Adobe Illustrator" 
tell application "System Events" 
    tell process "Adobe Illustrator CS5.1" 
     set xxx to value of attribute "AXMenuItemMarkChar" of menu item "Brushes" of menu 1 of menu bar item "Window" of menu bar 1 
     try 
      xxx 
     on error 
      -- insert your code 
      beep 2 
     end try 
    end tell 
end tell 
+0

甜。謝謝!現在正在研究如何檢查它是否爲'nil' :) – cwd

+0

你是一個職業選手。再次感謝你。 – cwd

+0

高興地幫助:) – adayzdone