|
|
10.8: New Notes App Service
Here's a slightly different version that doesn't overwrite your clipboard...
Open Automator and create a new Service. Set the Service to receive selected text in any application from the drop down menus. Drag Run AppleScript from the Utilities library into the workflow. Paste the below text in place of (* Your script goes here *):
10.8: New Notes App Service
Followed your instructions, but it didn't work for me. The new service showed up in the Services menu, but nothing happened when I selected text and then invoked the service. If it helps to diagnose the issue, Notes was already running, and I'm using OSX 10.8.3.
10.8: New Notes App Service
I'm replying to my own post to issue a correction: It turns out the script does work, but because it (deliberately) doesn't steal focus from whatever app you're using when you run the service, you have no way of knowing it did so unless you check, which I obviously didn't do.
10.8: New Notes App Service
Unlike the original hint, this version works for me.
10.8: New Notes App Service
Much better than the original, since you avoid GUI scripting!
However, rather than hard-coding the account to use into the script, it would be better to set the script to always use whatever account the user has set as their default account. So, replace the line that says tell account "iCloud"with one that says tell account id (do shell script "defaults read -app Notes DefaultAccount")
10.8: New Notes App Service
If the script doesn't work with rich text input, why do you need to convert the text to HTML? It makes the body use Times 12 instead of the default font. defaults -app doesn't work with Notes (or a few other applications) for me for some reason. And I didn't even have a DefaultAccount key. It would be easier to just specify the account and folder in the script. This also selects new notes: on run {input, parameters}
tell application "Notes"
tell account 1 to tell folder "Notes"
make new note with properties {body:input}
end tell
activate
end tell
tell application "System Events" to tell process "Notes"
set selected of row 1 of table 1 of scroll area 1 of group 1 of splitter group 1 of window 1 to true
set focused of group 1 of UI element 1 of scroll area 1 of group 2 of splitter group 1 of window 1 to true
end tell
end runEdited on Apr 13, '13 02:36:10AM by Lri
10.8: New Notes App Service
By converting to HTML you maintain line breaks, indentation, etc... Edited on Apr 13, '13 07:51:38PM by thawk9455
10.8: New Notes App Service
I took a little of each of the suggestions above. I didn't activate Notes since I might not want to leave the application I'm in. I did have a default account set so that code works for me. I also was able to get the HTML conversion to set the font size but the font portion doesn't seem to be working. I'd love to hear a way to fix that cleanly...
Edited on Apr 13, '13 08:05:11PM by thawk9455
10.8: New Notes App Service
And apparently the body is always HTML, so you also need to escape characters like <. Just adding white-space:pre seems to preserve whitespace though. on run {input, parameters}
tell application "Notes"
tell folder 1 of account 1
make new note with properties {body:"<body style=white-space:pre>" & my amp(input) & "</body>"}
end tell
activate
end tell
tell application "System Events" to tell process "Notes"
set selected of row 1 of table 1 of scroll area 1 of group 1 of splitter group 1 of window 1 to true
set focused of group 1 of UI element 1 of scroll area 1 of group 2 of splitter group 1 of window 1 to true
end tell
end run
on amp(input)
my replace(input, "&", "&")
my replace(result, "<", "<")
my replace(result, ">", ">")
end amp
on replace(input, x, y)
set text item delimiters to x
set ti to text items of input
set text item delimiters to y
ti as text
end replace
In the previous scripts you should use |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.17 seconds |
|