I wanted a quick way to show the 'Open Recent' menu of the current application. The following AppleScript was the solution.
set app_name to name of (info for (path to frontmost application))
tell application "System Events"
tell process app_name
-- Focus on the Apple menu upper left on your screen
click menu bar item "Apple" of menu bar 1
end tell
set myRight to ASCII character 29 -- Right arrow
set myDown to ASCII character 31 -- Down arrow
-- Go to file menu
repeat 2 times
keystroke myRight
end repeat
-- Highlight "Open Recent" menu
keystroke "Open Recent"
-- Show it
keystroke myRight
end tell
It won't work from within the (buggy) Script Editor, but works for me very well from Terminal:
$ cd /path/to/script/directory
$ sleep 5; osascript ./RecentDoc.scpt
(Switch to the app you wish to test during the sleep 5 bit.) You can also call it from QuickSilver, Butler, etc.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20060612020332864