• 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: Extracting Text from aa Window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extracting Text from aa Window


  • Subject: Re: Extracting Text from aa Window
  • From: Mr Tea <email@hidden>
  • Date: Sun, 31 Mar 2002 12:23:42 +0100

This from Ronald Hofmann - dated 31/3/02 11.55 am:

> tell application "TextEdit"
> set textVar to (get the contents of window 1)
> end tell

Hi, Ronald. You need something like...

tell application "TextEdit"
set textVar to (text of document 1)
end tell

An earlier thread on this list suggested that it's difficult/impossible to
get styled text out of TextEdit, but the above snippet will at least get the
text and the paragraph formatting.

> How can I save a text contained in a variable to my disk?

set theFile to open for access file (((path to desktop) as string) & "Saved
Text") with write permission
write textVar to theFile
close access theFile

(From 'set...' to '...permission' all on one line). If a text file with the
name and location that you specify already exists, the contents of textVar
will be appended to the existing contents, otherwise a new file will be
created.

> How can I load a textfile from my disk into a variable?

set theAlert to read file (((path to desktop) as string) & "Saved Text")

The read and write commands used here are included in the Standard Additions
OSAX.

You could also store the text as a property in your script, if it's saved as
an application, but that's probably not what you need.


T.
--
set ourQueenMotherStillBattingAlong to false
set nationalMourning to true
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Extracting Text from aa Window (From: Ronald Hofmann <email@hidden>)

  • Prev by Date: Extracting Text from aa Window
  • Next by Date: Re: ScriptEditor woes
  • Previous by thread: Extracting Text from aa Window
  • Next by thread: Re: Extracting Text from aa Window
  • Index(es):
    • Date
    • Thread