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.
[robg adds: Something I'm running on my machine, probably one of my input managers, is preventing this script from working on my machines. However, it's working for others based on my request for feedback on the forum site, so I thought I'd go ahead and post it. It will only work for those programs that have such a menu, and you'll need to make sure that Enable access for assistive devices is enabled in the Universal Access System Preferences panel.]

