Je veux créer un script qui enregistrera des documents safari en utilisant les événements système (commande + s) et je veux que le fichier soit toujours sauvegardé sur un chemin particulier. (Je pourrais prendre l'habitude de toujours enregistrer les fichiers safari dans un certain dossier mais ce n'est pas une solution robuste.) Comment puis-je m'assurer que les événements système enregistrent un document sur un certain chemin?applescript: comment choisir automatiquement d'enregistrer un document safari dans un CHEMIN PARTICULIER avec des événements système
1
A
Répondre
1
Directement à partir this MacRumors forum post:
tell application "Safari"
activate
end tell
tell application "System Events"
tell process "Safari"
click menu item "Copy" of menu "Edit" of menu bar 1
end tell
end tell
delay 1
set the_filename to (the clipboard) & ".html"
set the_filepath to "Macintosh HD:Users:Roy:Documents:" & the_filename
set the_shellfilepath to "'/Users/Roy/Documents/" & the_filename & ".download'"
set the_shellfilepath2 to "'/Users/Roy/Documents/" & the_filename & "'"
tell application "Safari"
activate
save document 1 in the_filepath
end tell
do shell script "mv " & the_shellfilepath & " " & the_shellfilepath2
Définir le chemin (the_shellfilepath
), selon le cas.
1
Changer le dossier d'une boîte de dialogue de fichier:
try
try -- this would result in an error when there's no clipboard
set old to the clipboard
end try
-- delay 1 -- for testing
-- activate application "Safari"
tell application "System Events"
keystroke "s" using command down
keystroke "g" using {shift down, command down}
delay 0.1
set the clipboard to "~/Movies/"
delay 0.1
keystroke "av" using command down
delay 0.1
keystroke return
delay 0.1
end tell
set the clipboard to old
end try
Enregistrer dans un dossier spécifique avec une URL partiellement codé comme un nom de fichier:
tell application "Safari"
set x to URL of document 1
set r to do shell script "echo " & quoted form of x & " | sed 's|/$||;s|:|%3A|g;s|/|%2F|g'"
do shell script "curl " & x & " > " & quoted form of ((system attribute "HOME") & "/Desktop/" & r & ".html")
end tell
Enregistrer dans un dossier spécifique mais en choisissant le fichier nom manuellement:
tell application "Safari"
set x to URL of document 1
set answer to text returned of (display dialog "" default answer ".html")
do shell script "curl " & x & " > " & quoted form of ((system attribute "HOME") & "/Desktop/" & answer)
end tell
Questions connexes
- 1. Utiliser AppleScript pour choisir un fichier dans Safari
- 2. AppleScript - Aide avec Safari
- 3. choisir un compte mail dans applescript
- 4. capturer des événements avec applescript
- 5. comment supprimer un chemin particulier dans cygwin
- 6. Comment lancer Safari et réinitialiser Safari avec applescript?
- 7. Répéter des événements iCal dans AppleScript
- 8. Objectif-C: Envoyer un email automatiquement (AppleScript)
- 9. Comment installer l'extension dans Safari par AppleScript
- 10. Comment délier tous les événements dans un div particulier
- 11. événements dans un système de fichiers watcher
- 12. Comment pourrait-on choisir un autre chemin de fusion?
- 13. télécharger le fichier sur le serveur dans un chemin particulier
- 14. Récupérer le contenu d'une fenêtre Safari dans Applescript
- 15. Comment créer un dossier avec un dossier intermédiaire avec Applescript?
- 16. Safari 5: Comment créer des signets via AppleScript dans un dossier spécial/pour> 1 onglets?
- 17. Arrêter éclipse d'importer automatiquement un paquet particulier
- 18. Chemin d'accès à un document
- 19. Événements AppleScript à distance
- 20. localiser des éléments dans des événements tactiles (safari mobile)
- 21. applescript choisir le titre du fichier
- 22. Ouvrir l'URL dans le nouvel onglet Safari avec AppleScript
- 23. Comment gérer les événements DOM dans un document incorporé?
- 24. Modification du document .doc en utilisant AppleScript
- 25. Comment automatiser un clic Safari avec AppleScript sans passer par JavaScript?
- 26. Comment choisir un chemin PDF à partir de ressources?
- 27. Commande Applescript dans la classe de document
- 28. Comment obtenir un tag particulier d'un document XML en python
- 29. Enregistrement d'un document dans un chemin de dossier partagé
- 30. Comment faire un sondage avec AppleScript