I am relatively new to AppleScript and I'm trying to find a way to programmatically enter a filename into a Save as PDF... dialog in Firefox.
I've gotten this far from searching the web. I've turned on the Accessibility Inspector in Xcode and I can inspect the various form elements.
on run {input, parameters}
tell application "Firefox" to activate
tell application "System Events"
tell process "Firefox"
click menu item "Print…" of menu "File" of menu bar 1
click menu button "PDF" of window "Print"
keystroke "S"
keystroke return
end tell
end tell
return input
end run
My situation is this: I have Firefox open with 20 tabs and I want to use AppleScript to save each tab as a pdf file with a "prefix"+"number" filename, e.g. "foo001.pdf", "foo002.pdf", etc.
- How do I set up a variable that I can increment in AppleScript?
- How do I enter a programmable filename into the appropriate field in the Save as PDF... dialog?
- Assuming that the script starts with the currently active tab in Firefox, how can I test when I've reached the last tab? (I suppose I could just let it select the "next" tab until it gets an error)
Thanks in advance.
Copyright Notice:Content Author:「Mac471」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30771572/how-to-use-applescript-to-enter-a-filename-in-firefox-save-as-dialog