[COLOR="Blue"][B]tell[/B] application [COLOR="Black"]"Preview"[/COLOR]
activate
[B]tell[/B] application [COLOR="Black"]"System Events"[/COLOR]
[B]tell[/B] application process [COLOR="Black"]"Preview"[/COLOR]
click menu item [COLOR="Black"]"Diaporama"[/COLOR] [B]of[/B] menu [COLOR="Black"]"Présentation"[/COLOR] [B]of[/B] menu bar item [COLOR="Black"]"Présentation"[/COLOR] [B]of[/B] menu bar [COLOR="Black"]1[/COLOR]
[B]end tell
end tell
end tell[/B][/COLOR]
[COLOR="Blue"][B]tell[/B] application [COLOR="Black"]"Finder"[/COLOR] [B]to[/B] shut down[/COLOR]
[COLOR="Blue"]do shell script [COLOR="Black"]"shutdown -h now"[/COLOR] [B]with[/B] administrator privileges[/COLOR]
Bloc de code:tell application "loginwindow" to «event aevtrsdn»
[COLOR="Blue"][COLOR="DimGray"]-- Pour éteindre le Mac :[/COLOR]
[B]tell[/B] application [COLOR="Black"]"loginwindow"[/COLOR] [B]to[/B] [COLOR="Black"]«[/COLOR]event [COLOR="Black"]aevtrsdn»[/COLOR]
[COLOR="DimGray"]-- Pour fermer la session :[/COLOR]
[B]tell[/B] application [COLOR="Black"]"loginwindow"[/COLOR] [B]to[/B] [COLOR="Black"]«[/COLOR]event [COLOR="Black"]aevtlogo»[/COLOR]
[COLOR="DimGray"]-- Pour redémarrer le Mac : [/COLOR]
[B]tell[/B] application [COLOR="Black"]"loginwindow"[/COLOR] [B]to[/B] [COLOR="Black"]«[/COLOR]event [COLOR="Black"]aevtrrst»[/COLOR] [/COLOR]
Quant à la troisième question, il est possible d'éteindre le Mac en faisant:Avant l'extinction effective, toutes les applications ayant un document non enregistré d'ouvert afficheront un message de confirmation ("Souhaitez-vous enregistrer les modifications...").Bloc de code:[COLOR="Blue"][B]tell[/B] application [COLOR="Black"]"Finder"[/COLOR] [B]to[/B] shut down[/COLOR]
Une autre solution, beaucoup plus violente celle-là est:Un login et un mot de passe administrateur sont requis dans l'opération (on peut les ajouter au script). Mais en contrepartie l'extinction est immédiate et sans appel. Attention au risque de perte des documents en cours d'édition !Bloc de code:[COLOR="Blue"]do shell script [COLOR="Black"]"shutdown -h now"[/COLOR] [B]with[/B] administrator privileges[/COLOR]
Comment faire svp ? ( pour les ajouter au script)
Quant à la troisième question, il est possible d'éteindre le Mac en faisant:Avant l'extinction effective, toutes les applications ayant un document non enregistré d'ouvert afficheront un message de confirmation ("Souhaitez-vous enregistrer les modifications...").Bloc de code:[COLOR="Blue"][B]tell[/B] application [COLOR="Black"]"Finder"[/COLOR] [B]to[/B] shut down[/COLOR]
Une autre solution, beaucoup plus violente celle-là est:Un login et un mot de passe administrateur sont requis dans l'opération (on peut les ajouter au script). Mais en contrepartie l'extinction est immédiate et sans appel. Attention au risque de perte des documents en cours d'édition !Bloc de code:[COLOR="Blue"]do shell script [COLOR="Black"]"shutdown -h now"[/COLOR] [B]with[/B] administrator privileges[/COLOR]
Dans le cas présent, ça devrait donner :Quel est donc le moyen pour les ( mot de passe et nom du compte) ajouter au script ?
:love:
[COLOR="Blue"]do shell script [COLOR="Black"]"shutdown -h now"[/COLOR] password [COLOR="Black"]"[I]mot_de_passe[/I]"[/COLOR] [B]with[/B] administrator privileges[/COLOR]
[COLOR="Blue"]do shell script [COLOR="Black"]"shutdown -h now"[/COLOR] user name [COLOR="Black"]"[I]login[/I]"[/COLOR] password [COLOR="Black"]"[I]mot_de_passe[/I]"[/COLOR] [B]with[/B] administrator privileges[/COLOR]
Violent hein !? C'est sûr que ne c'est pas chez moi que je ferais tourner ça. Je n'ai pas envie de perdre mes billes, et puis je ne mets jamais mon mot de passe administrateur en clair dans un script...:rolleyes::afraid::hosto::hosto:
tell application "loginwindow" to «event aevtslep»