• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: saving displayed text on a web page as rtf
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: saving displayed text on a web page as rtf


  • Subject: Re: saving displayed text on a web page as rtf
  • From: "koenig.yvan" <email@hidden>
  • Date: Fri, 05 Jul 2013 19:44:58 +0200


Le 05/07/2013 à 19:10, 2551 <2551phil@gmail.com> a écrit :


On 5 Jul 2013, at 23:43, Lists <email@hidden> wrote:


A while back, Bill Cheeseman posted some code for printing to PDF from the front application. This script is based on his code.

tell application "System Events"
set appname to name of first process whose frontmost is true
end tell

activate application appname
tell application "System Events"
tell process appname
-- insert GUI Scripting statements here
keystroke "p" using command down
set PDFButton to menu button "PDF" of sheet 1 of window 1
click PDFButton
click menu item "Save As PDF…" of menu 1 of PDFButton
delay 1
click button "Save" of window 1
end tell
end tell

Woah! Now that's some slick code (oh man, don't you just hate the gurus being gurus sometimes… ;) ).

Thanks for posting! Just needs the filename added to the save dialogue and looks more or less done!

Here is an enhanced version tested under 10.8.4.

I forced Safari because when I launch the script from the Script Editor its the script window which is stored.

set _filename to "Reports"
set _dateStamp to (do shell script "date +_%Y-%m-%d_%H.%M.%S")
set _newName to _filename & _dateStamp & ".pdf"

tell application "System Events"
set appname to name of first process whose frontmost is true
end tell
if appname is "AppleScript Editor" then set appname to "Safari"

activate application appname
tell application "System Events"
tell process appname
set nbw to count windows
-- insert GUI Scripting statements here
keystroke "p" using {command down}
(*
Wait for the availability of the sheet *)
repeat
if exists sheet 1 of window 1 then exit repeat
end repeat
set PDFButton to first menu button of sheet 1 of window 1
click PDFButton
click menu item 2 of menu 1 of PDFButton
(*
Wait for the availability of the Print sheet *)
repeat
if exists sheet 1 of sheet 1 of window 1 then exit repeat
end repeat
(*
Force Desktop as target folder *)
keystroke "d" using {command down}
(*
Set the name of the new PDF *)
set value of text field 1 of sheet 1 of sheet 1 of window 1 to _newName
keystroke return
end tell
end tell



KOENIG Yvan (VALLAURIS, France) vendredi 5 juillet 2013 19:44:53



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: saving displayed text on a web page as rtf
      • From: 2551 <email@hidden>
References: 
 >saving displayed text on a web page as rtf (From: 2551 <email@hidden>)
 >Re: saving displayed text on a web page as rtf (From: Kaydell Leavitt <email@hidden>)
 >Re: saving displayed text on a web page as rtf (From: 2551 <email@hidden>)
 >Re: saving displayed text on a web page as rtf (From: Deivy Petrescu <email@hidden>)
 >Re: saving displayed text on a web page as rtf (From: 2551 <email@hidden>)
 >Re: saving displayed text on a web page as rtf (From: Luther Fuller <email@hidden>)
 >Re: saving displayed text on a web page as rtf (From: 2551 <email@hidden>)
 >Re: saving displayed text on a web page as rtf (From: Lists <email@hidden>)
 >Re: saving displayed text on a web page as rtf (From: 2551 <email@hidden>)

  • Prev by Date: Re: saving displayed text on a web page as rtf
  • Next by Date: AUTO: Allyn Martin is out of office.
  • Previous by thread: Re: saving displayed text on a web page as rtf
  • Next by thread: Re: saving displayed text on a web page as rtf
  • Index(es):
    • Date
    • Thread