Applescript to click menu item in Lightroom 5

applescript

I am using a script found elsewhere on this site. But I can't figure out how to modify it to fit my use. As written the script activates the submenu I need but I can't figure out how to click an item on this submenu. I've tried all the variations of the line for "Rejected" I always get an error message saying "Can't get menu xxx…" The actual menu structure is: menu bar item: Photo, sub item with triangle: Set Flag, which expands to a submenu that includes "Rejected".

Hope that's clear.

tell application "System Events" to tell process "Adobe Photoshop Lightroom 5"
set frontmost to true
tell menu bar item "Photo" of menu bar 1
    click
    click menu item "Set Flag" of menu 1
    --works fine to here

    click menu item "Rejected" of menu "Set Flag"


end tell

end tell

Best Answer

Found this which did the trick.

tell application "System Events" to tell process "Adobe Photoshop Lightroom 5"
set frontmost to true
tell menu bar 1
    tell menu bar item "Photo"
        tell menu "Photo"
            tell menu item "Set Flag"
                tell menu "Set Flag"
                    click menu item "Rejected"
                end tell
            end tell
        end tell
    end tell
end tell
end tell