• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Recent Items
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recent Items


  • Subject: Re: Recent Items
  • From: Shane Stanley <email@hidden>
  • Date: Thu, 10 Apr 2014 22:39:56 +1000

On 10 Apr 2014, at 8:14 am, koenig.yvan <email@hidden> wrote:

Maybe somebody will have posted a fine code before I wake up.

Alas, you're probably wide awake by now. Here's an ASObjC-based handler to get just the names:

use framework "Foundation"

on returnRecentAppNames()
set thePath to current application's NSString's stringWithString:"~/Library/Preferences/com.apple.recentitems.plist"
set theDict to current application's NSDictionary's dictionaryWithContentsOfFile:(thePath's stringByExpandingTildeInPath())
return (theDict's valueForKeyPath:"RecentApplications.CustomListItems.Name") as list
end returnRecentAppNames

And if you want the paths:

use framework "Foundation"

on returnRecentAppPaths()
set thePath to current application's NSString's stringWithString:"~/Library/Preferences/com.apple.recentitems.plist"
set theDict to current application's NSDictionary's dictionaryWithContentsOfFile:(thePath's stringByExpandingTildeInPath())
set theBookmarkData to (theDict's valueForKeyPath:"RecentApplications.CustomListItems.Bookmark") as list
set thePaths to {}
repeat with aData in theBookmarkData
set theInfo to (current application's NSURL's resourceValuesForKeys:{current application's NSURLPathKey} fromBookmarkData:aData)
set end of thePaths to (theInfo's valueForKey:(current application's NSURLPathKey)) as text
end repeat
return thePaths
end returnRecentAppPaths

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Recent Items
      • From: "koenig.yvan" <email@hidden>
References: 
 >Recent Items (From: "koenig.yvan" <email@hidden>)

  • Prev by Date: Re: NSString in ApplescriptObjC
  • Next by Date: Re: NSString in ApplescriptObjC
  • Previous by thread: Re: Recent Items
  • Next by thread: Re: Recent Items
  • Index(es):
    • Date
    • Thread