Applescript - Take Screenshot of ENTIRE Web Page - Safari

I edited message #25.
Now the script localize the menu item “Capture Screenshot”

I would be interested by feedback from users running other language than English or French.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 9 mars 2020 16:49:29

Here are links to threads in which I posted scripts triggering combo boxes.

CAUTION: some are old and some problems related to encoding strike.

I never found free time to edit my messages in which such problem strike.

http://macscripter.net/viewtopic.php?id=45805
http://macscripter.net/viewtopic.php?pid=190622#p190622
http://www.macscripter.net/viewtopic.php?id=45871 - I think that it’s the thread with my more recent script triggering these objects. It contains a script which I use quite daily.
https://macscripter.net/viewtopic.php?id=43790
https://macscripter.net/viewtopic.php?id=44237
https://macscripter.net/viewtopic.php?id=45268
https://macscripter.net/viewtopic.php?id=45277
https://macscripter.net/viewtopic.php?id=45401
https://macscripter.net/viewtopic.php?id=45420
https://macscripter.net/viewtopic.php?id=45983

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 9 mars 2020 21:03:12

Alternatively, you can press Cmd+Shift+C when devtools open in Chrome to select an element then its available in console with variable name $0

An alternative that might be considered is exporting a web page as a single-page PDF, which could then be converted to a PNG if desired. The PDF and a screenshot would not be identical but relatively close in most cases. Also, exporting a PDF doesn’t work on every web site, but it’s pretty reliable in my testing. This script needs refinement but works on my Sonoma computer.

set {hours:h, minutes:min, seconds:s} to (current date)
set theTime to text 2 thru -1 of ((1000000 + (h * 10000) + (min * 100) + s) as text)
set the clipboard to "Safari " & theTime

tell application "System Events"
	tell process "Safari"
		if (exists window 1) is false then error number -128
		set frontmost to true
		click menu item "Export as PDF…" of menu "File" of menu bar 1 -- localize if necessary
	end tell
	delay 1.0 -- test different values
	keystroke "v" using command down
	delay 0.5 -- test different values
	keystroke return
end tell
1 Like

Just reporting that this worked great on Macintouch, but oddly I get no text in the pdf from Macscripter, whether all text is selected or none.

Sonoma 14.2.1/Intel

kerflooey. Thanks for testing my script. I tried my script on MacScripters, and it worked fine. We’re both running Sonoma, so that’s not the answer. Perhaps another forum member will try my script.