Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'An AppleScript to open the Show Recent menu' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to open the Show Recent menu
Authored by: cougar718 on Jun 20, '06 07:26:46PM
How bout this instead? This code is more concise and does not require key codes. Most importantly it will check whether or not the "Open Recent" item exists before trying to 'show' it.
To adjust the delay, or remove it, simply do so :P

on run
	delay 5
	set strAppName to name of (info for (path to frontmost application))
	tell application "System Events"
		tell process strAppName
			tell menu bar 1
				if (exists menu item "Open Recent" of menu "File") then
					click menu "File"
					click menu item "Open Recent" of menu "File"
				end if
			end tell
		end tell
	end tell
end run

I've tested this code on my machine and there were no problems. But in the event there is a problem, let me know by either replying to this hint or emailing me at cougar@bat-country.net.

---
Rick alias cougar

[ Reply to This | # ]

An AppleScript to open the Show Recent menu
Authored by: Lutin on Jun 23, '06 04:12:40AM
My first try was something along those lines, following Apple examples.
But, that didn't work, and I couldn't figure out why.
Testing your suggestion, I understood: if you run it from Script Editor, it doesn't work.
It's why I came with the much uglier version, but I admit I prefer a lot yours.
I adapted your version so it works from within the finder as well.

on run
	set strAppName to name of (info for (path to frontmost application))
	tell application "System Events"
		tell process strAppName
			tell menu bar 1
				if (strAppName is equal to "Finder.app") then
					if (exists menu item "Recent Folders" of menu "Go") then
						click menu "Go"
						click menu item "Recent Folders" of menu "Go"
					end if			
				else					
					if (exists menu item "Open Recent" of menu "File") then
						click menu "File"
						click menu item "Open Recent" of menu "File"
					end if
				end if
			end tell
		end tell
	end tell
end run


[ Reply to This | # ]
An AppleScript to open the Show Recent menu
Authored by: cougar718 on Jun 23, '06 08:55:56AM

Awesome! Glad it works for you and I'm glad you edited it. Love to see that! It seems that there are some Input Manager plugins that break the communication to 'System Events' which in turn break your/our script.

Now I cannot believe Apple does not have a standard shortcut for the 'Open Recent' menu. I guess it's the Developer's and ultimately Apple for making it a Aqua Guide rule because in any nib, I'm sure you could use <modifier> + O to show the recent menu.

Real quick: Your idea makes the 'Open Recent' menu like a window which you can choose the document from which why others find it so convenient.

---
Rick alias cougar



[ Reply to This | # ]
An AppleScript to open the Show Recent menu
Authored by: TvE on Jun 24, '06 12:33:50AM

Yes - a feature that should be implemented in the OS.

I can recommend the way Zend Studio (a PHP IDE) implemented it.

Type CTRL-SHIFT-R and you get (a seperate window) with a list of the (10?) most recently opened files…

CMD-SHIFT-R is probably a better shortcut for a Mac user - Zend Studio is X-platform



[ Reply to This | # ]
An AppleScript to open the Show Recent menu
Authored by: Lutin on Jun 24, '06 02:08:16PM
Awesome! Glad it works for you and I'm glad you edited it. Love to see that!
I like it as well. That's why I would like an option to get an email every time a comment is posted.
I'm sure sharing and exchange like that would happen more often, and be of better quality.
Currently, after a few months, the comments of an hint get lost far in the site.
I know there is now RSS for the comments, but there is too much traffic. I just want to be able to watch a few threads.
robg?

[ Reply to This | # ]
An AppleScript to open the Show Recent menu
Authored by: ehouwink on Jun 26, '06 01:06:21PM

I tried to work around the problem that some apps do not have a "Recent Files" menu item but "Recent Documents" (like Ragtime)
The following script tries to find out what the "Recent" menu title is and addresses further action to that.

<code>
tell application "System Events"
set strAppName to name of some application process whose frontmost is true
tell process strAppName
tell menu bar 1
if (strAppName is equal to "Finder.app") then
if (exists menu item "Recent Folders" of menu "Go") then
click menu "Go"
click menu item "Recent Folders" of menu "Go"
end if
else
set recentmenu to (every menu item of menu "File" whose name contains "Recent")
if recentmenu = {} then return
set recentmenu to item 1 of recentmenu
tell me to set rr to name of menu items of menu 1 of recentmenu
beep
end if
end tell
end tell
end tell

tell application "System Events" to ¬
set fApp to some application process whose frontmost is true
tell fApp
activate
set theItem to choose from list rr
end tell
if theItem is false then return
set theItem to theItem as string

using terms from application "System Events"
tell application "System Events" to set frontmost of process strAppName to true
click menu item theItem of menu 1 of recentmenu
return theItem
end using terms from
</code>



[ Reply to This | # ]
An AppleScript to open the Show Recent menu
Authored by: ehouwink on Jun 26, '06 01:26:44PM

Pfff, in TextEdit, the lists created with the previous script appear to contain mini-icons that get translated as question marks, so I had to filter that out:

[code]
tell application "TextEdit" to activate

tell application "System Events"
set strAppName to name of some application process whose frontmost is true
tell process strAppName
tell menu bar 1
if (strAppName is "Finder") then
if (exists menu item "Recent Folders" of menu "Go") then
click menu "Go"
click menu item "Recent Folders" of menu "Go"
end if
else
set recentmenu to (every menu item of menu "File" whose name contains "Recent")
if recentmenu = {} then return
set recentmenu to item 1 of recentmenu
tell me to set rr to name of menu items of menu 1 of recentmenu
beep
end if
end tell
end tell
end tell

tell application "System Events" to ¬
set fApp to some application process whose frontmost is true
tell fApp
activate
set theItem to choose from list rr
end tell
if theItem is false then return
set theItem to theItem as string

-- filteren van "?" uit TextEdit's mini-icons in dialoog
if character 1 of theItem contains "?" then set theName to text from character 2 to -1 of theItem

set theItem to theName as string

using terms from application "System Events"
tell application "System Events" to set frontmost of process strAppName to true
set rr to every menu item of menu 1 of recentmenu whose name contains theItem
if rr ≠ {} then click item 1 of rr
return theItem
end using terms from
[/code]



[ Reply to This | # ]