• 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: Thu, 04 Jul 2013 16:32:09 +0200

I made tests with an edited version because I'm running the system in French.



set _filename to "Reports"
set _dateStamp to (do shell script "date +_%Y-%m-%d_%H.%M.%S")
set _newFile to (path to desktop as string) & _filename & _dateStamp & ".rtf"


tell application "Safari" to activate
tell application "System Events"
tell application process "Safari"
keystroke "a" using {command down}
delay 0.2
keystroke "c" using {command down}
end tell
end tell

delay 0.5

tell application "Safari" to close current tab of window 1

tell application "TextEdit"
activate
set cod to count documents # ADDED
set f to make new document
repeat until (count documents) > cod # ADDED
delay 0.01
end repeat
# Thanks to the code adde above we are sure that the new document is available
# Extraneous code to be sure that the document is rtf, not text
tell application "System Events" to tell process "TextEdit" to tell menu bar 1 to tell menu bar item 5 to tell menu 1 to tell menu item -1 to enabled
if not result then tell application "System Events" to tell process "TextEdit" to tell menu bar 1 to tell menu bar item 5 to tell menu 1 to click menu item 4 (* switch from Text to Rich Text (RTF) *)
end tell

tell application "System Events"
tell application process "TextEdit"
keystroke "v" using {command down}
end tell
end tell

tell application "TextEdit"
save f in file _newFile
close window 1
quit
end tell

It works well but something bothers me.
The Copy task grabs text AND graphics so when the script pastes in TextEdit the new document switch from rtf to rtfd and the app issue a dialog asking if I want to keep the changes brought to the document.
Alas, this action is not "seen" by AppleScript and I must be in front of the machine to screenshot to your personal address.get rid of the dialog.

I post a screenshot to your personal address.

Yvan KOENIG (VALLAURIS, France) jeudi 4 juillet 2013 16:31:57


 _______________________________________________
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: "koenig.yvan" <email@hidden>
References: 
 >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: Re: saving displayed text on a web page as rtf
  • 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