Le 12/04/2014 à 17:26, Thomas Fischer < email@hidden> a écrit : Hello,
just for the record I want to state that this can be done with acceptable speed with vanilla AppleScript (so that my last script doesn't stand as such). The first time might be a little slow to get System Events started, afterwards it's quick (in the order of 0.1 sec.). This doesn't solve the problem of getting the current version of the recent application, and I don't know if there is way to force the Finder to update it.
…
It seems that you missed what was the goal to reach.
I ran your script and was asked to select an application in the list appsNames
appsNames was
{"1: Éditeur AppleScript.app", "2: Numbers.app", "3: iBooks.app", "4: iTunes.app", "5: App Store.app", "6: Safari.app", "7: Mail.app", "8: keep_clean_prefs.app", "9: tout quitter.app", "10: consulter AAPL.app", "11: open URL from clipboard.app", "12: créee fil.app", "13: ManOpen.app", "14: Moniteur d’activité.app", "15: Préférences Système.app", "16: Xcode.app", "17: Utilitaire d’archive.app", "18: trier uninstall.app", "19: Numbers.app", "20: TextEdit.app"}
Alas doing that I can't know which application Numbers.app is the 2.3 one and which is the 3.2 one. It was the real goal to reach. Other apps are available only once. The problem is with iWork components because iWork '09 offer true applications when iPlay '13 offer just toys. But I can't wait too long before learning what is already available in these toys.
As I am curious, I looked at the list named recentApps and got an awful result.
{"/0/Applications/Utilities/AppleScript Editor.app", "/Applications/iWork '09/Numbers.app", "/ä/Applications/iBooks.app", "/ä/Applications/iTunes.app", "/è/Applications/App Store.app", "/ä/Applications/Safari.app", "/Ü/Applications/Mail.app", "//Applications/Applications perso/ouverture au deÌmarrage/keep_clean_prefs.app", ( eÌ was supposed to be «é») "/d/Users/••••••••••/Desktop/tout quitter.app", "/l/Users/••••••••••/Desktop/consulter AAPL.app", "/|/Users/••••••••••/Desktop/open URL from clipboard.app", "/d/Users/••••••••••/Desktop/creÌee fil.app", ( eÌ was supposed to be «é») "/,/Applications/Applications perso/ManOpen.app", "/,/Applications/Utilities/Activity Monitor.app", "/ü/Applications/System Preferences.app", "/$/Applications/Applications_MAS/Xcode.app", "/T/System/Library/CoreServices/Archive Utility.app", "/l/Users/••••••••••/Desktop/trier uninstall.app", "/ä/Applications/Numbers.app", "/ä/Applications/TextEdit.app"}
If I select item 19, the script try to start "/ä/Applications/Numbers.app", and of course I get the error : error "Le fichier /ä/Applications/Numbers.app est introuvable." number -43 from current application
If I select item 8, the script try to start : "//Applications/Applications perso/ouverture au deÌmarrage/keep_clean_prefs.app", and of course I get : error "Le fichier //Applications/Applications perso/ouverture au deÌmarrage/keep_clean_prefs.app est introuvable." number -43 from current application
This said, I looked in depth in your code to see how you converted so quickly hexadecimal into decimal then character. So I understood why you got extraneous characters at the beginning of the pathnames. You aren't extracting the pathname stored as a single string near the end of the bookmark (highlighted in blue) but you rebuild it from its components (highlighted in purple) stored separately at the beginning.
Here is a raw bookmark. In the hexadecimal contents I put the semi-colon in red and the pathname in blue «data 626F6F6B60030000000004103000000000000000000000000000000000000000000000000000000000000000000000008C0200000C000000010100004170706C69636174696F6E7312000000010100004170706C69636174696F6E7320706572736F000018000000010100006F7576657274757265206175206465CC816D61727261676514000000010100006B6565705F636C65616E5F70726566732E6170701000000001060000040000001800000034000000540000000800000004030000EAF91801000000000800000004030000720000000000000008000000040300008B010000000000000800000004030000BD74DA000000000010000000010600008800000098000000A8000000B8000000080000000004000041B5E162D5000000240000000101000042423535374136352D454137322D333846332D424344362D38354145424342394233303518000000010200008100000001000800EF17000001000800000000000000000001000000010100002F0000000000000001050000DF00000001020000613836613634663532313439333939646466663933346363326364646462626338396163656338333B30303030303030303B30303030303030303B303030303030303030303030303032303B636F6D2E6170706C652E6170702D73616E64626F782E726561642D77726974653B30303030303030313B30313030303030313B303030303030303030306461373462643B2F6170706C69636174696F6E732F6170706C69636174696F6E7320706572736F2F6F7576657274757265206175206465CC816D6172726167652F6B6565705F636C65616E5F70726566732E61707000009C000000FEFFFFFF01000000000000000C00000004100000700000000000000005100000C80000000000000010100000F00000000000000040100000E000000000000000022000009001000000000000102000001001000000000000112000004401000000000000122000002401000000000000132000003401000000000000202000007001000000000000302000009C0100000000000080F00000A401000000000000» Now is the same deciphered by my very first script. A lot of characters don't appear because their ID is lower than 32.
(*book`0?ApplicationsApplications persoouverture au deÌ?marragekeep_clean_prefs.app4Têùr?1⁄2tÚ??¨¸A23ÓÜMacintosh HD??-èAµábÕ$BB557A65-EA72-38F3-BCD6-85AEBCB9B305?ï/ßa86a64f52149399ddff934cc2cdddbbc89acec83;00000000;00000000;0000000000000020;com.apple.app-sandbox.read-write;00000001;01000001;0000000000da74bd;/applications/applications perso/ouverture au deÌ?marrage/keep_clean_prefs.app?<thorn>ÿÿÿpÈ<eth>@à ? D $ 4 p0 ??<eth>?*)
The problem with your code is that it is fooled by what it scan at the beginning of the bookmark.
My understanding is that if you replace :
set my theChars to {} & the id of (text 59 thru -1 of n) by set my theChars to {} & the id of (text 123 thru -1 of n)
you will get paths starting with their true starting point. Of course this is not sufficient to solve the problem due to unicode characters stored as more than one byte. I underlined the groups of three bytes describing the character «é»
Yvan KOENIG (VALLAURIS, France) samedi 12 avril 2014 21:42:45
|