• 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
Recent Items
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Recent Items


  • Subject: Recent Items
  • From: "koenig.yvan" <email@hidden>
  • Date: Thu, 10 Apr 2014 00:14:24 +0200

Im asked for a script allowing to start a recently used application without triggering the Apple Menu.

I wrote such a script but I'm not satisfied of it because the deciphering of the datas stored in the preference file storing the info upon these item is slow and mistreat the Unicode characters which we use in French.

Here is a draft of the script.

#[SCRIPT]
set recentPrefs to (path to preferences folder from user domain as text) & "com.apple.recentitems.plist"
tell application "System Events"
set recentApps to {}
value of property list file recentPrefs
RecentApplications of result
set theCustomItems to CustomListItems of result
set recentApps to {}
repeat with anItem in every item of theCustomItems
set end of recentApps to my decipherAbookmark(bookmark of anItem)
end repeat
end tell

set maybe to choose from list recentApps
if maybe is false then error number -128
activate application (maybe as text)

#=====
#
# It's this handler which is boring me
#
on decipherAbookmark(bMark)
try
bMark as text
on error errMsg number errNbr
offset of "«data" in errMsg
set errMsg to text (result + 6) thru -1 of errMsg
offset of "»" in errMsg
set errMsg to text 1 thru (result - 1) of errMsg
set enListe to {}
repeat with i from 1 to count errMsg by 2
try
tell me to set end of enListe to character id (my hex2num(text i thru (i + 1) of errMsg))
end try
end repeat
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ""}
set enTexte to enListe as text
set enTexte to item -2 of my decoupe(enTexte, ".app")
set enTexte to item -1 of my decoupe(enTexte, ";") & ".app"
set AppleScript's text item delimiters to oTIDs
return enTexte
end try
end decipherAbookmark

#=====

on decoupe(t, d)
local oTIDs, l
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
set l to text items of t
set AppleScript's text item delimiters to oTIDs
return l
end decoupe

#=====

on hex2num(t)
return ((offset of (text item 1 of t) in "0123456789ABCDEF") - 1) * 16 + (offset of (text item 2 of t) in "0123456789ABCDEF") - 1
end hex2num

#=====
#[/SCRIPT]

I'm quite sure that there is a better way to convert the piece of Hex datas into text.
Probably I have a Shane Stanley's library to do that but my memory tell me that somebody published a tip using a temporary file to do decipher the bookmark.
It's passed midnight here so it's time to sleep.

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

Yvan KOENIG (VALLAURIS, France) jeudi 10 avril 2014 00:13:28




 _______________________________________________
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: Shane Stanley <email@hidden>
    • Re: Recent Items
      • From: Thomas Fischer <email@hidden>
    • Re: Recent Items
      • From: Thomas Fischer <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: names of a record's items
  • Next by thread: Re: Recent Items
  • Index(es):
    • Date
    • Thread