2012-11-12 8 views
7

Có cách nào để có danh sách tất cả các mục menu dưới tiêu đề menu như File hoặc Edit với AppleScript không?Tôi làm cách nào để có được danh sách các mục menu có Applescript?

Tôi đã tìm thấy một số câu hỏi có liên quan, nhưng không có gì chính xác. Không may mắn trên Google.

Tôi đang cố gắng lấy danh sách tệp nào đang mở trong menu Window của Photoshop và tìm ra xem tệp nào có dấu kiểm.

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

Tôi nghĩ rằng tôi có thể có thể làm phần thứ hai bằng cách sử dụng một cái gì đó như "In Applescript, how can I find out if a menu item is selected/focused?" và Accessibility Inspector vì nó có AXMenuItemMarkChar

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

Trả lời

9

tôi không có Photoshop nhưng điều này phù hợp với 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 

Để có được một attribu te bạn có thể sử dụng:

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 

nil kịch bản:

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

ngọt. Cảm ơn bạn! Bây giờ làm việc trên làm thế nào để kiểm tra nếu nó là 'nil' :) – cwd

+0

bạn là một chuyên nghiệp. cám ơn bạn một lần nữa. – cwd

+0

Rất vui được trợ giúp :) – adayzdone