0

I was able to get the context menu up with applescript tell perform action "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

This got the menu up. But I am not able to access any of the menu items. How can I access menu items for a file in finder?

Matthew0898
  • 263
  • 2
  • 13
  • 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 I am not able to get the menu items after I click on AXShowMenu – user1519766 Sep 30 '15 at 23:38

1 Answers1

0

You can use keystroke to select the menu item:

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
jweaks
  • 3,674
  • 1
  • 19
  • 32