I had to learn the Python syntax as AppleScript will be deprecated in the next version.
I spent hours to rewrite my triggers, schedules and action groups using Python and it's almost done.
I have one remaining AppleScript: its purpose is to copy 3 variables in an Excel file.
maison
entree
couloir
Here is the code I started to convert:
- Code: Select all
import applescript
maison = indigo.variables[1054921485] # "CompteurMaison"
entree = indigo.variables[202160838] # "CompteurEntree"
couloir = indigo.variables[1615311783] # "CompteurCouloir"
Script ='''
property hier : string
tell application "IndigoServer"
set maison to value of variable "CompteurMaison"
set entree to value of variable "CompteurEntree"
set couloir to value of variable "CompteurCouloir"
end tell
my dateActuelle()
tell application "System Events"
tell application "Finder" to open (name of startup disk & ":Library:Application Support:Perceptive Automation:Indigo 7.2:Databases:Compteurs de passages.xlsx") as alias
end tell
delay 3
tell application "Microsoft Excel"
set derniereLigne to first row index of (find column 2 what "")
set derniereLigneDate to ("B" & derniereLigne)
set value of cell derniereLigneDate to hier
if maison > 0 then
set derniereLigneCompteurMaison to ("C" & derniereLigne)
set value of cell derniereLigneCompteurMaison to maison
end if
if entree > 0 then
set derniereLigneCompteurEntree to ("D" & derniereLigne)
set value of cell derniereLigneCompteurEntree to entree
end if
if couloir > 0 then
set derniereLigneCompteurCouloir to ("E" & derniereLigne)
set value of cell derniereLigneCompteurCouloir to couloir
end if
«event coreslct» cell derniereLigneDate
delay 3
save
end tell
on dateActuelle()
set hier to (current date) - 86400
set {jourChiffre, mois, annee} to {day, month, year} of hier
set listeMoisUS to {January, February, March, April, May, June, July, August, September, October, November, December}
repeat with i from 1 to 12
if month of hier is (item i of listeMoisUS) then set moisChiffre to i
end repeat
set hier to (jourChiffre & "/" & moisChiffre & "/" & annee) as string
end dateActuelle
'''
ScriptComplet = applescript.AppleScript(source= Script)
reply = ScriptComplet.run()
How can I rid of
- Code: Select all
tell application "IndigoServer"
set maison to value of variable "CompteurMaison"
set entree to value of variable "CompteurEntree"
set couloir to value of variable "CompteurCouloir"
end tell
Thanks for your help.