2015-09-25 78 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