• 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: "koenig.yvan" <email@hidden>
  • Date: Thu, 10 Apr 2014 18:11:51 +0200


Le 10/04/2014 à 14:39, Shane Stanley <email@hidden> a écrit :

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/>


I can't post before because I was busy in the garden.

As always your answer it's perfect.

use theLib : script "RecentItems Lib"

theLib's returnRecentAppPaths()
(*
 {"/Applications/TextEdit.app", 
"/Applications/Applications_MAS/ClamXav.app", 
"/Applications/Applications perso/ouverture au démarrage/keep_clean_prefs.app", 
"/Applications/Safari.app", 
"/Applications/Applications perso/HexEdit Release/HexEdit.app", 
"/Applications/Mail.app", 
"/Applications/Utilities/AppleScript Editor.app", 
"/Applications/System Preferences.app", 
"/Applications/Preview.app", 
"/Volumes/Adobe Flash Player Installer/Install Adobe Flash Player.app"}

Now, I must try to find where is stored the up-to-date list of recent items.
The one stored in "~/Library/Preferences/com.apple.recentitems.plist" is out of date.
In fact I don't know how often it's refreshed.

The up-to-date list of names is :

set theList to my nameOfSubMenuItems("Finder", 1, 9)
set trueList to {}
repeat with aString in theList
set aString to contents of aString
if aString is missing value then exit repeat
if (aString is not "Applications") and aString ends with ".app" then
set end of trueList to aString
end if
end repeat
trueList
--> {"Calculette.app", "ClamXav.app", "HexEdit.app", "keep_clean_prefs.app", "Moniteur d’activité.app", "Pages.app", "Pages.app", "Récupère le chemin.app", "Safari.app", "TextEdit.app"}

#=====

on nameOfSubMenuItems(theApp, mt, mi)
activate application theApp
tell application "System Events" to tell (first process whose frontmost is true) to tell menu bar 1 to ¬
tell menu bar item mt to tell menu 1 to tell menu item mi to tell menu 1 to return name of menu items
end nameOfSubMenuItems

#=====


I tried to force Finder to quit but it didn't updated the file.

Time to start a new safari.

Yvan KOENIG (VALLAURIS, France) jeudi 10 avril 2014 18:11:46



 _______________________________________________
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: Thomas Fischer <email@hidden>
    • Re: Recent Items
      • From: Kevin Meaney <email@hidden>
References: 
 >Recent Items (From: "koenig.yvan" <email@hidden>)
 >Re: Recent Items (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: names of a record's items
  • Next by Date: Re: names of a record's items
  • Previous by thread: Re: Recent Items
  • Next by thread: Re: Recent Items
  • Index(es):
    • Date
    • Thread