• 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
Pages and Applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pages and Applescript


  • Subject: Pages and Applescript
  • From: Yvan KOENIG <email@hidden>
  • Date: Fri, 2 Apr 2010 19:30:16 +0200

Hello

I'm a bit annoyed with Pages.

If the selection is made of two different strings of text,

I may grab several useful infos with this trick :

tell application "Pages" to tell document 1
set theSel to get the selection
try
theSel * 1
on error errmsg
log errmsg
end try
end tell

which return this log :

tell application "Pages"
get selection of document 1
{text from character 209 to character 210 of body text of document id 10302510, text from character 222 to character 223 of body text of document id 10302510}
(*Impossible de transformer {text from character 209 to character 210 of body text of document id 10302510 of application "Pages", text from character 222 to character 223 of body text of document id 10302510 of application "Pages"} en type number.*)
end tell

or

tell application "Pages"
get selection of document 1
{text from character 30 to character 31 of object text of shape 1 of foreground layer of page 2 of document id 5462874, text from character 39 to character 40 of object text of shape 1 of foreground layer of page 2 of document id 5462874}
(*Impossible de transformer {text from character 30 to character 31 of object text of shape 1 of foreground layer of page 2 of document id 5462874 of application "Pages", text from character 39 to character 40 of object text of shape 1 of foreground layer of page 2 of document id 5462874 of application "Pages"} en type number.*)
end tell

or

tell application "Pages"
get selection of document 1
{text from character 26 to character 27 of object text of text box 1 of foreground layer of page 2 of document id 5462874, text from character 32 to character 33 of object text of text box 1 of foreground layer of page 2 of document id 5462874}
(*Impossible de transformer {text from character 26 to character 27 of object text of text box 1 of foreground layer of page 2 of document id 5462874 of application "Pages", text from character 32 to character 33 of object text of text box 1 of foreground layer of page 2 of document id 5462874 of application "Pages"} en type number.*)
end tell

which may be easily deciphered with a bit of trickery.

Alas, when the selection is a single chunck of text, if grabbing the properties of the selection, I may know 
that it sits in a given page
that it starts at character offset x (in a container which is not reported)
that it contains contents
and
that it's length is, what a surprise, length of the contents.

But I found no way to grab the infos about the container which may be :
body text of
or
object text of shape x of foreground layer of
or
object text of text box y of foreground layer of

At least from my point of view, the problem is that when the selection is a single object,
get selection doesn't return a selection's descriptor but the selection's contents, and get a reference to the selection behaves the same.

I think that a logical behaviour would be:

get the selection returns a description 
and
get contents of the selection returns … the contents

which is the real behaviour when several objects are selected.

I wish to know your advice before filing a bug report.

Yvan KOENIG (VALLAURIS, France) vendredi 2 avril 2010 19:30:11



 _______________________________________________
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: Pages and Applescript
      • From: Axel Luttgens <email@hidden>
  • Prev by Date: Check for Download completed in Safari
  • Next by Date: Re: Check for Download completed in Safari
  • Previous by thread: Re: Check for Download completed in Safari
  • Next by thread: Re: Pages and Applescript
  • Index(es):
    • Date
    • Thread