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


Click here to return to the 'Updated for 10.6' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Updated for 10.6
Authored by: troelssj on Nov 03, '10 02:47:08PM
Thanks for the reply, yours is a much more elegant solution. But I had to use

set itemList to every menu item of every menu of first menu bar whose name contains "Open Recent"
instead of

set itemList to every menu item of every menu of first menu bar whose name contains "Recent"
Otherwise the script just activates "Recent Items" in all programs. Unfortunately, this breaks the desired behavior in Finder (and also in a different application I use often, which has two different open recent items). But this should be easily fixed with an exception for these two programs.

[ Reply to This | # ]
Updated for 10.6
Authored by: tedw on Nov 03, '10 03:10:40PM

I'm confused - every app I've tried this on returns only one item (either 'open recent', 'recent items', or in the Finder's case 'recent folders'). what app has more than one of these?



[ Reply to This | # ]
Updated for 10.6
Authored by: troelssj on Nov 04, '10 01:27:10AM

When I execute the script as you wrote it, it just activates "Recent Items" (located under the menu with the  logo). Maybe this menu item has a different name on your machine? If you use a non-english localized this might be the explanation.

Regarding the program I mentioned which had multiple menu items containing "Recent", I was referring to a statistical program called Stata, which has both a "Open Recent" and a "Open Recent Do-files" menu item. The "Open Recent" is located higher up in the menu, so this one gets activated (but I prefer it to activate "Open Recent Do-files" instead). It is probably impossible to deal with this without adding an exception for this specific program.



[ Reply to This | # ]
Updated for 10.6
Authored by: tedw on Nov 04, '10 01:42:55AM
Ah, I get it. I have Recent Items disabled in my Apple menu, so I forgot it was there. That's easily fixed, however. just change line 5 to say:

repeat with idx from 2 to count of itemList

The '2' causes the script to skip over the Apple menu and start with the first application-specific menu. You could even use '3' if you wanted (a recent items list is not likely to occur before the File menu).

[ Reply to This | # ]

Updated for 10.6
Authored by: troelssj on Nov 04, '10 02:49:58AM
Thanks, it works great now!

In the script I use, I will probably also add an exception to TextMate, since for some strange reason it takes the script about 5 seconds to locate the open recent item in the menu bar (I had this issue with my original script as well). So for users of TextMate, I would suggest adding the following

if (frontApp is equal to "TextMate") then
	tell process frontApp
		key code 120 using control down
		key code 124
		key code 124
		key code 125
		key code 125
		key code 125
		key code 125
		key code 125
		key code 124
	end tell
end if
It ins't pretty, but beats waiting for 5 seconds.

[ Reply to This | # ]
Updated for 10.6
Authored by: tedw on Nov 04, '10 08:21:56AM

That's interesting: I wonder what causes that delay? you might try adding the line <tt>set quit delay to 0</tt> somewhere in the System Events tell block - that tells System Events to stay open all the time so that you don't get startup delays on the next invocation.



[ Reply to This | # ]
Updated for 10.6
Authored by: troelssj on Nov 04, '10 03:08:23PM

Adding "set quit delay to 0" didn't change the behavior.

I have noticed that after a few seconds, a rotating gear appears in the right side of the menu bar - where the wi-fi, bluetooth and speaker icons are located. I am guessing it indicates that the script is waiting for something to complete. Now that I think of it, TextMate has a rather complicated menu structure - one menu item has more than 40 subitems, all of which have many subsubitems. To make things worse, these items are related to various bundles, which can be changed by the user, so TextMate might have to rebuild the menu bar when the script asks for items containing the word "recent".



[ Reply to This | # ]