J'essaie de créer un script qui ouvre un fichier swf avec safari et ensuite l'imprimer en format pdf en utilisant la fonction intégrée "Save as PDF". Jusqu'à présent, mon code ressemble à ceci:GUI Applescript sur Mountain Lion
set appleworksFolder to choose folder
tell application "Finder"
set folderItems to (files of entire contents of appleworksFolder)
repeat with I from 1 to number of items in folderItems
set the_doc to item I of folderItems
set doc_name to name of the_doc as text
tell application "Finder"
set the clipboard to doc_name & ".pdf"
end tell
if name of the_doc is not ".DS_Store" then
try
tell application "Safari"
activate
open the_doc
tell application "System Events"
tell application process "Safari"
delay 1
click menu item "Print…" of menu "File" of menu bar 1
delay 5
click menu button "PDF" of window "Print" of application process "Safari" of application "System Events"
delay 1
click menu item "Save as PDF…" of menu "PDF" of menu button "PDF" of window "Print" of application process "Safari" of application "System Events"
delay 1
keystroke "v" using command down
click button "Save" of window "Save" of application process "Safari" of application "System Events"
delay 8
keystroke "w" using command down
delay 0.5
end tell
end tell
end tell
end try
end if
end repeat
end tell
Cela fonctionne à voir le dialogue d'impression, mais il ne semble pas cliquer sur le bouton de menu pdf ne soyez pas si loin que cela. Je me demandais si c'était un problème avec le lion de montagne qui ne me laissait pas utiliser l'applescript pour contrôler les boutons, et si oui, y a-t-il une solution? Toute aide serait grandement appréciée!
Vous pouvez également utiliser [wkpdf] (http://plessl.github.com/wkpdf/) pour créer les fichiers PDF. – user495470