I was writing a basic AppleScript and cannot seem to get a Safari web page to print. This has to be simple but I need help.
Thanks
Model: G5
Browser: Safari 417.8
Operating System: Mac OS X (10.4)
I was writing a basic AppleScript and cannot seem to get a Safari web page to print. This has to be simple but I need help.
Thanks
Model: G5
Browser: Safari 417.8
Operating System: Mac OS X (10.4)
enro:
I have not tested this, but try this out:
tell application "System Events"
tell process "Safari" to keystroke "p" using command down
end tell
You need to be sure that your GUI scripting is enabled (Enable access for assistive devices) which is located in your Universal access tab of System Preferences.
Thanks that worked well in combination with Finder. It brought the print screen up which is a lot further than I was 30 minutes ago. Any idea how to have it actually print. As it stands I have to press the print key.
Assuming you don’t need to change any settings, enro, all you need to do is hit the return button. However, your script first needs to make sure the print window has had time to appear - so it’s just a matter of expanding on Craig’s suggestion a little:
tell application "System Events" to tell process "Safari"
set frontmost to true
keystroke "p" using command down
tell sheet 1 of window 1
repeat until exists
delay 0.1
end repeat
keystroke return
end tell
end tell
Kai,
Thanks that too was very helpful.
Enro