Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm trying to create a "Service" in Automator that changes the font of the selected text in the frontmost app.

share|improve this question
1  
The guide on How to Ask will help you refine your question by showing what you've tried and/or what exactly "you don't get". If you don't get a good answer, feel free to try editing in some details or links on what question you used and what step is failing or doesn't make sense. We love details here. –  patrix Feb 27 '13 at 18:30
    
I tried this too and have not been able to do so. I would ask Ben Waldie from automatedworkflows.com He might know. Phil –  Philippe Dube Feb 28 '13 at 3:10

1 Answer 1

You could assign a shortcut to a script like this:

tell application "System Events" to tell (process 1 where frontmost is true)
    set {c1, c2} to value of attribute "AXSelectedTextRange" of text area 1 of scroll area 1 of window 1
end tell
tell application (path to frontmost application as text) to tell document 1
    tell characters c1 thru c2
        set font to "Menlo"
        set size to 18
    end tell
end tell

It works with TextEdit and WriteRoom, but it probably needs to be modified for other applications.

Another really awful option:

try
    set old to the clipboard as record
end try
do shell script "textutil -stdin -stdout -format html -convert rtf <<< '<span style=\"font: 18px Menlo\">a</span>' | pbcopy"
tell application "System Events"
    keystroke "v" using command down
    keystroke "c" using {option down, command down}
    keystroke "z" using command down
    keystroke "v" using {option down, command down}
end tell
delay 0.05
try
    set the clipboard to old
end try
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.