• 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: variables vrs properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variables vrs properties


  • Subject: Re: variables vrs properties
  • From: KOENIG Yvan <email@hidden>
  • Date: Wed, 5 Jan 2011 19:40:24 +0100


Le 5 janv. 2011 à 18:29, Bruce Robertson a écrit :


On Jan 5, 2011, at 8:31 AM, KOENIG Yvan wrote:


Le 5 janv. 2011 à 16:59, Robert Poland a écrit :


Luther,

If I remember right with Snow Leopard, saving as an application creates an application bundle.

My question; Would an application typically execute faster that a script?

As far as I know, scripts are faster than application applets.

This is why some one posted a workaround some days ago :

Just use in the run piece of code an instruction running an encapsulated script.

The result is amazing.

Alas I didn't found a way to do the same with a droplet.
I'm unable to pass the list of selected items to the script to run.

Yvan KOENIG (VALLAURIS, France) mercredi 5 janvier 2011 17:31:26



Hm, sounds interesting, can you provide more detail on that message, did not find it after a brief search.

Bruce Robertson


My memory was wrong, the tip was not delivered a few words ago.
It was before 2010/06/16 because I have an applet in which I use it created/modified at this date.

So, maybe this memory was also wrong about the media in which I got the tip. Maybe it was in MacScripter.

When my G5 died, I didn't import my old mails in the new machines so, I can't search among them.

Here is the named script.

--[SCRIPT récupérer_restaurer_position_icônes]
(*
Enregistrer le script en tant que Progiciel (Application sous 10.6.x) : récupérer_restaurer_position_icônes.app
Installer dans le Dock.

Sélectionner les icônes du bureau dont la position doit pouvoir être rétablie.
Lancer le script
Cliquer le bouton "Enregistrer leur position"
Un fichier texte contenant les informations relatives à ces icônes sera créé dans le dossier défini à partir de la property 'dest'
Par défaut c'est dans "<startupVolume>:Users:<userAccount>:Library:Application Support:".

Pour remettre les icônes en place, lancer l'application et cliquer le bouton "Rétablir leur position"

--=====

Save the script as an Application Bundle (Application under 10.6.x) : récupérer_restaurer_position_icônes.app
Install it in the Dock for easy access.

Select Desktop's icons whose location must be reset when needed.
Run the script.
Click the button "Get there position".
A text file containing the datas linked to these icons will be created in the folder defined according to the property 'dest'.
Default location is : "<startupVolume>:Users:<userAccount>:Library:Application Support:".


Run the script and click the button "Reset there position" to move the icons back to their original location.

--=====

bureau_complet KOENIG (VALLAURIS, France)
2010/03/16

*)
--=====--=====

property tout_le_bureau : true

property dest : 3
(*
1 = liste dans : "<startupVolume>:Users:<userAccount>:Library:Preferences:"
2 = liste dans : "<startupVolume>:Users:<userAccount>:Applications:Utilities:"
3 = liste dans : "<startupVolume>:Users:<userAccount>:Library:Application Support:"
*)
property nomDuRapport : "position des icones.txt"
property rapport : {}

--=====

on run
run script mon_script
end run

script mon_script
my nettoie()
if dest = 1 then
set p2d to path to preferences as text (*
"<startupVolume>:Users:<userAccount>:Library:Preferences:" *)
else if dest = 2 then
set p2d to path to utilities folder from user domain as text (* 
"<startupVolume>:Users:<userAccount>:Applications:Utilities:" *)
else
set p2d to (path to library folder from user domain as text) & "Application Support:" (*
"<startupVolume>:Users:<userAccount>:Library:Application Support:" *)
end if


set p2r to p2d & nomDuRapport
if my parleAnglais() then
set prompt to "What to do with icons ?"
set {btn1, btn2, btn3} to {"Cancel", "Get their position", "Reset their position"}
else
set prompt to "Que faire avec les icônes ?"
set {btn1, btn2, btn3} to {"Abandonner", "Enregistrer leur position", "Rétablir leur position"}
end if


set maybe to button returned of (display dialog prompt buttons {btn1, btn2, btn3} default button 3)
if maybe is btn1 then (*
Cancel / Annuler *)
error number -128
else if maybe is btn2 then (*
Get their position / Enregistrer leur position *)
tell application "Finder"
set itms to name of every item of the desktop
repeat with itm in itms
try
set {x, y} to get desktop position of item itm
copy "" & itm & return & x & ", " & y to end of my rapport
end try
end repeat
end tell -- Finder
set rapport to my recolle(my rapport, return)
(*
crée un fichier texte dans le dossier "Bibliothèque:Application Support" du compte utilisateur *)
tell application "System Events"
if exists file p2r then delete file p2r
make new file at end of folder p2d with properties {name:nomDuRapport}
end tell -- System Events
write rapport to (p2r as alias)
else (*
Reset there position / Rétablir leur position *)
set my rapport to paragraphs of (read file p2r)
repeat with i from 1 to ((count of rapport) - 1) by 2
try
set itm to item i of rapport
tell application "Finder" to set desktop position of item itm to my decoupe(item (i + 1) of rapport, ", ")
end try
end repeat
tell application "Finder" to update folder p2d
end if
my nettoie()
end script

--=====

on nettoie()
set my rapport to {}
end nettoie

--=====

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

--=====

on recolle(l, d)
local t
set AppleScript's text item delimiters to d
set t to l as text
set AppleScript's text item delimiters to ""
return t
end recolle

--=====

on parleAnglais()
local z
try
tell application "Finder" to set z to localized string "AL1"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais

--=====
--[/SCRIPT]

Yvan KOENIG (VALLAURIS, France) mercredi 5 janvier 2011 19:39:38


 _______________________________________________
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

References: 
 >variables vrs properties (From: Jim Brandt <email@hidden>)
 >Re: variables vrs properties (From: Luther Fuller <email@hidden>)
 >Re: variables vrs properties (From: Robert Poland <email@hidden>)
 >Re: variables vrs properties (From: KOENIG Yvan <email@hidden>)
 >Re: variables vrs properties (From: Bruce Robertson <email@hidden>)

  • Prev by Date: Re: variables vrs properties
  • Next by Date: Re: variables vrs properties
  • Previous by thread: Re: variables vrs properties
  • Next by thread: Re: variables vrs properties
  • Index(es):
    • Date
    • Thread