2015-09-25 32 views
0

我能得到使用AppleScript 上下文菜單上來講執行操作「AXShowMenu」蘋果腳本訪問上下文菜單的元素文件

tell application "System Events" to tell process "Finder" tell window {window name} tell splitter group 1 tell splitter group 1 UI elements tell scroll area 1 UI elements tell group 1 UI elements tell image {filename} perform action "AXShowMenu" end tell end tell end tell end tell end tell end tell 

這引起了菜單了。但是我無法訪問任何菜單項。我如何在finder中訪問文件的菜單項?

+0

後。你的。碼。 – jweaks

+0

告訴應用程序 「系統事件」 告訴過程 「查找」 \t告訴窗口{窗口名稱} \t \t告訴分離器組1 \t \t \t告訴分離器組1個 \t \t \t \t UI元素 \t \t \t \t訴說滾動區域1 \t \t \t \t \t UI元素 \t \t個\t \t \t訴說組1 \t \t \t \t \t \t UI元素 \t \t \t \t \t \t告訴圖像{文件名} \t \t \t \t \t \t \t執行操作 「AXShowMenu」 \t \t \t \t \t \t烯ð告訴 \t \t \t \t \t年底告訴 \t \t \t \t年底告訴 \t \t \t年底告訴 \t \t年底告訴 \t年底告訴 我無法得到我後點擊AXShowMenu菜單項 – user1519766

回答

0

您可以使用按鍵來選擇菜單項:

set filename to "test.jpg" 
tell application "Finder" to activate 
delay 0.2 
tell application "System Events" 
    tell process "Finder" 
     -- set theTarget to value of attribute "AXFocusedUIElement" 
     set theTarget to group 1 of scroll area 1 of splitter group 1 of splitter group 1 of window 1 
     tell theTarget 
      tell image filename to perform action "AXShowMenu" 
      delay 0.2 
      keystroke "open" 
      keystroke return 
     end tell 
    end tell 
end tell