Re: scripting font change in TextEdit / NoteTaker, etc
Re: scripting font change in TextEdit / NoteTaker, etc
- Subject: Re: scripting font change in TextEdit / NoteTaker, etc
- From: Martin Crisp <email@hidden>
- Date: Tue, 20 Jul 2004 21:09:42 +1000
- Organization: Tesseract Computing
If this is a repeat I apologise, I first sent quoting the wrong
email address...
On Tue, 20 Jul 2004 17:32:48 +1000, Martin Crisp wrote
(in message <
email@hidden>):
>
On Mon, 19 Jul 2004 04:02:30 +1000, Michael Cytrynowicz wrote
>
(in message
>
<r02010100-1034-A3BB5AD4D8E411D8A73C000393C49D60@[172.26.0.2):
>
>
> Hi list,
>
>
>
> I thought it would be pretty trivial, but I can't figure how to do it.
>
> What I need to do is in TextEdit - and alsi in Notetaker - to be able to
>
> change the font of selected text to, say, verdana 10.
>
>
Don't have Notetaker, but changing the font of particular parts of
>
a TextEdit document is trivial. Changing the font of the selection,
>
however, is basically impossible [unless you can calculate where it
>
is as a range of characters in the text of the document].
There is a reason I leave myself such 'outs'...
[snip]
Looking a little closer...
tell application "System Events"
tell application process "TextEdit"
tell text area 1 of scroll area 1 of UI element 1
set {startPos, endPos} to value of (attribute
"AXSelectedTextRange")
end tell
end tell
end tell
tell application "TextEdit"
set font of characters startPos thru endPos of document 1 to
"Palatino"
set size of characters startPos thru endPos of document 1 to 17
end tell
Note the complete lack of error checking :-)
[it works even with the spell checking window and the page setup
panel showing.... but you should probably check that there is an
open document, if there isn't the menu bar is ui element 1]
Have Fun
Martin
_______________________________________________
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.