Suddenly the script no longer works in Snow Leopard … I think I misspelled parts of it … thanks for any help
set specificFolder to (choose folder) -- *** destination folder ***--
tell application "FileMaker Pro Advanced"
tell database "Names_Ids"
tell table 1
set theseURLs to field "Link" -- get all URL
set theseName to field "Name"
set theseID to field "ID"
end tell
end tell
end tell
set firstTime to true
set tc to (count theseURLs)
repeat with i from 1 to tc
set archiveName to item i of theseName & " " & item i of theseID
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
keystroke "p" using command down
tell front window
repeat until exists sheet 1
delay 0.1
end repeat
tell sheet 1
click menu button "PDF"
repeat until exists menu 1 of menu button "PDF"
delay 0.1
end repeat
click menu item "Save as PDF." of menu 1 of menu button "PDF"
end tell
end tell
repeat until exists window "Save"
delay 0.2
end repeat
tell window "Save"
keystroke "g" using {command down, shift down}
repeat until exists sheet 1
delay 0.2
end repeat
repeat while exists sheet 1
delay 0.2
end repeat
set value of text field 1 to (archiveName & ".pdf") as string
click button "Save"
end tell
end tell
end tell
end repeat
set value of text field 1 to (archiveName & ".pdf") as string
should be moved up and in between the two repeat loops, after the one waiting for the sheet for a path to come up, and before the other loop waiting for it to disappear again, at almost the very end of your script.
Thanks however I get this error:
System Events got an error: Can’t get text field 1 of process “Safari”. Invalid index.
this was how I changed the script according to your kind suggestion
set specificFolder to (choose folder) -- *** destination folder ***--
tell application "FileMaker Pro Advanced"
tell database "Names_Ids"
tell table 1
set theseURLs to field "Link" -- get all URL
set theseName to field "Name"
set theseID to field "ID"
end tell
end tell
end tell
set firstTime to true
set tc to (count theseURLs)
repeat with i from 1 to tc
set archiveName to item i of theseName & " " & item i of theseID
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
keystroke "p" using command down
tell front window
repeat until exists sheet 1
delay 0.1
end repeat
tell sheet 1
click menu button "PDF"
repeat until exists menu 1 of menu button "PDF"
delay 0.1
end repeat
click menu item "Save as PDF." of menu 1 of menu button "PDF"
end tell
end tell
set value of text field 1 to (archiveName & ".pdf") as string
repeat until exists window "Save"
delay 0.2
end repeat
tell window "Save"
keystroke "g" using {command down, shift down}
repeat until exists sheet 1
delay 0.2
end repeat
repeat while exists sheet 1
delay 0.2
end repeat
click button "Save"
end tell
end tell
end tell
end repeat
tell window "Save"
keystroke "g" using {command down, shift down}
repeat until exists sheet 1
delay 0.2
end repeat
set value of text field 1 of sheet 1 to archiveName & ".pdf"
click button "Go" of sheet 1
repeat while exists sheet 1
delay 0.2
end repeat
click button "Save"
end tell
Is rather strange
In the selected folder I find the first file with the names as in FMP and the PDF extension but the script stops thelling me as follows:
System Events got an error: Can’t get menu button “PDF” of sheet 1 of window 1 of process “Safari”.
While looking at the script it performs exactly what is required but then it halts while is should repeat opening the following url.
It looks as if the script tries to repeat the print action after it is already done …
I used your original scripts, and changed something. ( I just tested the Safari part, on what was active in my window, as I haven’t got your database, nor can I see how you load the Url’s into Safari.
property save_win_title : "Save"
set specificFolder to (choose folder) -- *** destination folder ***--
tell application "FileMaker Pro Advanced"
tell database "Names_Ids"
tell table 1
set theseURLs to field "Link" -- get all URL
set theseName to field "Name"
set theseID to field "ID"
end tell
end tell
end tell
set firstTime to true
set tc to (count theseURLs)
repeat with i from 1 to tc
set archiveName to item i of theseName & " " & item i of theseID
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
keystroke "p" using command down
tell front window
repeat until exists sheet 1
delay 0.1
end repeat
tell sheet 1
click menu button "PDF"
delay 3
repeat until exists menu 1 of menu button "PDF"
delay 0.1
end repeat
click menu item 2 of menu 1 of menu button "PDF"
end tell
end tell
repeat until exists window (my save_win_title)
delay 0.2
end repeat
tell window (my save_win_title)
keystroke "g" using {command down, shift down}
repeat until exists sheet 1
delay 0.2
end repeat
set value of text field 1 of sheet 1 to (archiveName & ".pdf") as string
click button 2 of sheet 1
repeat while exists sheet 1
delay 0.2
end repeat
click button 1
end tell
end tell
end tell
end repeat