Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Create Palm Desktop memo entry from selection Apps
Cocoa services are cool, and "Make entry from selection" kinda services work very well with Cocoa apps such as Macjournal and Sbook. Well, I like and am sticking with Palm Desktop (it is still the fastest of them all, and syncs smoothest with my Clie), but since it is a Carbon app, it doesn't support services. I really want to select text in the frontmost application and make a memo out of it; needing it with Safari the most, mainly to grab recipes from Epicurious or some other notables, and stick them in the memo list.

Well, with a lot of help from the nice listers at Macscripter.net, I came up with the following AppleScript. Save it into ~/Library/Scripts (I use the name makeMemo.applescript), make sure the AppleScript menu is visible in your menubar, and off you go. When you want to make a memo in Palm Desktop while surfing in Safari, just select the text and choose the makeMemo script from your menubar. A new memo item will be created. Tweak as desired.

tell application "Safari" to set contentsTxt to ¬
 (do JavaScript "getSelection()" in document 1)
set contentsTxt to «class ktxt» of (result as record)
set titleTxt to text 1 thru 20 of contentsTxt
tell application "Palm Desktop"
  activate
  try
    make new memo with properties ¬
     {title:titleTxt, contents:contentsTxt}
    on error msg
     display dialog msg
  end try
end tell
[robg adds: I haven't tested this one...]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[13,211 views]  

Create Palm Desktop memo entry from selection | 29 comments | Create New Account
Click here to return to the 'Create Palm Desktop memo entry from selection' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create Palm Desktop memo entry from selection
Authored by: timswan on Dec 11, '03 11:56:59AM

When I try to run or save this script I get a Syntax Error: Expected "given", "with", "without", other parameter name, etc. but found "{". Any ideas?



[ # ]
Create Palm Desktop memo entry from selection
Authored by: gdsimms on Dec 11, '03 02:34:07PM

I'm getting this error in Script Editor when I run it:

Can't make "" into a record.



[ # ]
Create Palm Desktop memo entry from selection
Authored by: pkishor on Dec 11, '03 05:29:24PM

Hi,

I created this hint (and the script). Just type the script exactly as shown (be careful of the line breaks, etc.). It does work, as corroborated by others in this thread. Else, you will have to provide more details on what you typed, and what exactly the error was. Keep in mind, this script works only with Safari, and I have tested it only on Panther, with PD 4.1



[ # ]
Create Palm Desktop memo entry from selection
Authored by: pkishor on Dec 11, '03 05:34:44PM

did you type the hint exactly as it is? keep in mind, that funny, elbow type character is a line continuation character... the entire statement is one line. Since that is the only statement with {, it is likely you typed it on separate lines.



[ # ]
Create Palm Desktop memo entry from selection
Authored by: timswan on Dec 11, '03 09:58:51PM

Yes, it's typed *exactly* as it is here. Weird that it's not working.



[ # ]
Create Palm Desktop memo entry from selection
Authored by: joeholmes on Dec 11, '03 12:58:12PM

This tip worked perfectly for me. And it's really handy!

(By the way, you can use Apple's iSync and the Palm Desktop Memo Hotsync at the same time. Only calendar, to do, and address books need to go one way or the other.)

One thing I'd like to see is a way to get this to work with any app. I wonder if it's possible...

And I didn't have the problem the other user had -- check to see that the pasted script is identical to the way it looks on the Mac OS X Hints page. Sounds like a typo or broken line...

-=-Joe



[ # ]
Create Palm Desktop memo entry from selection
Authored by: pkishor on Dec 11, '03 05:32:16PM

Ya, I wrote this hint, and I would like to extend this to beyond Safari as well. Unfortunately I know very little about AppleScript (about all I know is represented in this script). I think it should not be difficult to refer to the frontmost window, but the do Javascript method is very Safari specific. The regular AppleScript way of grabbing selection doesn't seem to work with Safari.



[ # ]
Can it work in Mozilla / Firebird?
Authored by: alexmathew on Dec 11, '03 02:00:04PM

The Javascript line does not compile if the application is changed to Mozilla.
Great hint - will be veru useful if it works in Mozilla!
Am



[ # ]
Can it work in Mozilla / Firebird?
Authored by: pkishor on Dec 11, '03 05:36:45PM

Sorry, the do Javascript bit is very Safari-specific. I don't have Moz/Firebird on my Mac so I can't do much. But you could try replacing it with some standard AppleScript way -- there is something to the effect of grabbing selectedText. Look at the AppleScript tutorial on Apple's site.



[ # ]
Create Palm Desktop memo entry from ANY app
Authored by: klktrk on Dec 11, '03 06:00:03PM
The way to get this to work from any app is to require the user to first hit Cmd+C to put the selection into the clipboard. then you can just use this script. (There is no universal way in AppleScript to get at the selection in any and every app-- even with UI scripting):
set selectedText to do shell script "pbpaste"
display dialog "Enter a title for your memo: " ¬
default answer "" default button "OK"
set titleText to text returned of result
set confirmationMessage to "This is your new memo
Title: " & titleText & "

Body: " & selectedText

display dialog the confirmationMessage ¬
buttons {"Cancel", "Send to Palm memo"} ¬ 
default button 2 with icon 1 giving up after 10

set userChoice to the button returned of the result


if userChoice is "Send to Palm memo" then
	tell application "Palm Desktop"
  activate
  try
    make new memo with properties ¬
     {title:titleText, contents:selectedText}
    on error msg
     display dialog msg
  end try
end tell
end if


Look out for line breaks!

[ # ]
Create Palm Desktop memo entry from ANY app
Authored by: sjk on Dec 11, '03 06:27:31PM

Thanks for the script. Hope to get it working since it could become quite useful.

Pretty sure I've got it copied and compiled properly tho' every test returns this:

Palm Desktop got an error: Can't make some data into the expected type.

Entries with only a date field show up in Palm Desktop Memos but disappear when its opened.

I'm running 10.3.1, PD 4.1.



[ # ]
Create Palm Desktop memo entry from ANY app
Authored by: pkishor on Dec 11, '03 06:59:13PM

as is, this script won't work. The reason is Unicode -- PD doesn't support Unicode, so you have to extract plain text out of the selection. Look out for the following line in the original script I wrote

<code>
set contentsTxt to «class ktxt» of (result as record)
</code>

without that, an empty memo will be created, and will promptly disappear.



[ # ]
Create Palm Desktop memo entry from ANY app
Authored by: sjk on Dec 11, '03 07:14:31PM

Ahh, thanks for the explanation. I figured there was a good reason for doing that.



[ # ]
Create Palm Desktop memo entry from ANY app
Authored by: timswan on Dec 13, '03 09:53:37AM

Keep in mind that many of us are not applescripters, so when you say "Watch the line breaks" many of us aren't quite sure what you mean. Should the script match exactly what is shown on the html page, including the "¬", or should they be deleted to make one line.

Little things like that are important when you're trying to spread your extremely helpful code. I'm just totally unable to get any of these scripts to work -- I'm starting to think I have a script editor problem. I keep getting a Syntax Error: Expected "given", "with", "without", other parameter name, etc. but found "{". no matter how carefully I type in the code.



[ # ]
Create Palm Desktop memo entry from selection
Authored by: macman13 on Dec 11, '03 06:26:58PM
Here is an update to your script that seems to work fine for me:

set contentsTxt to the clipboard as string
set contentsTxt to «class ktxt» of (result as record)
set titleTxt to text 1 thru 20 of contentsTxt
tell application "Palm Desktop"
	activate
	try
		make new memo with properties ¬
			{title:titleTxt, contents:contentsTxt}
	on error msg
		display dialog msg
	end try
end tell

With this code, highlight the text you wish to copy and press Command-C as you copy a piece of text. Once it is on the clipboard you run the script. This actually works better for me and does not require javascript. I noticed a difference in the two scripts:

1. If I use the script with javascript I get weird characters in the memo text.

2. If I use the revised script that actually copies from the clipboard, I do not get these weird character. in fact I get an actual COPY of the text I highlited.

Safari and javascript are no longer required. Now it copies the text directly from the clipboard so any text you save to the clipboard will be turned into a memo for your palm. Granted this adds one more step to the process, but it is quick step that produces much more readable text in the Palm memo.

Thanks.
SA:)

---
\\"I can do everything on my Mac I used to do on my PC, plus alot more ...\\"
--Me

[ # ]

Create Palm Desktop memo entry from selection
Authored by: sjk on Dec 11, '03 06:52:27PM

Ahh, that works. Later I'll try adding the interactive pieces from klktrk version.

Thanks for all the contributions.



[ # ]
Create Palm Desktop memo entry from selection
Authored by: pkishor on Dec 11, '03 07:01:09PM

sweet. Ya, those weird chars do appear -- I think they are just line breaks being goofed up. Your script does add one extra step, but is more universal. Good job.,



[ # ]
Create Palm Desktop memo entry from selection
Authored by: mspalacios on Dec 11, '03 09:26:53PM

This is probably OT, but what I'm looking for is to continue using memos but to consult them from an app that is *NOT* PalmDesktop. I find it slow, kludgy and just plain ugly. I've already converted to iCal and Address Book and sync via iSync, but I've got the memos going to PalmDesktop. I would be happy with an cocoa or even carbon app that would allow me to read the PalmDesktop memo file and display it. No need to update. Does anyone know of an app that would do this?

Thanks.



[ # ]
Create Palm Desktop memo entry from selection
Authored by: DeltaTee on Dec 12, '03 08:30:43AM

Yes, inquiring minds would like to know. I haven't found one that will work yet.



[ # ]
Create Palm Desktop memo entry from selection
Authored by: punkish on Dec 12, '03 08:47:32AM

Interesting that you find PD slow and kludgy. While I too find it ugly (well, "ugly" is a harsh word, lets say, its not Aqua pretty), I find it to be blindingly fast. That is the one main reason (and flawless syncing with Clie being the other) that I continue to prefer it over iCal and AB -- on my iBook G3/600 both Apple apps are slower than Heinz ketchup. I will put up with ugly anytime for the sake of speed.
<p>
Anyway, that was just a bit of editorializing, but now to your question. Why do you continue to use PD at all. If you are only using for its memo capabilities, move to Sbook. Sbook is all Cocoa, all free, and syncs with AB, supports all the services, and can happily store all your memos. You can also use MacJournal, another fine app that will do the same. Yet another choice is Voodoo Lite. All these apps are free, and are all Cocoa.<p>
Hth.



[ # ]
Apple ABook/iCal vs. Palm Desktop
Authored by: sjk on Dec 13, '03 09:10:53PM

I also find Palm Desktop performance much better than Address Book and iCal on my iBook 600. Then there's iSync... besides being slow as molasses it does such a poor job synchronizing with the corresponding PIMs on my Tungsten E that I just can't make it useful even tho' I'd like to. And my hunch is Apple won't make any significant Palm-related iSync updates before Palm OS 6 is released. 'Tis a shame.

For now I'm reluctantly sticking with Palm Desktop and found the Plain Gray decor is more tolerable than the others. So far I've just been using the Contacts and Memos conduits until I better understand how best to sync with DateBk5 so I won't unexpectedly "misplace" information entered with it or Palm Desktop.



[ # ]
Palm Desktop Memo replacement
Authored by: Fofer on Dec 12, '03 09:52:51AM

I know of two:

http://www.queuesoft.jp/ipalmmemo-e.html

http://mac-huwis.lut.ac.uk/~wis/programs/NoteTaker/NoteTaker.html

The first one is probably what you want. It came out recently and is a slick and simple replacement for Palm's Memo component. It comes with it's own conduit so it doesn't even have to "read" the data from your original Palm User Data file.

Personally I use Now Contact for addresses and Now Up to Date for events and To-Do's on my Treo 600. And I just leave Palm Desktop set up with only the "Memos" window open (this window positing is persistent when I quit and relaunch.) Doesn't seem slow to me.



[ # ]
Create Palm Desktop memo entry from selection
Authored by: Fofer on Dec 12, '03 11:09:00AM
Perhaps someone better at HTML than me could post this (and future?) AppleScripts as clickable links... this would help lots of folks with typos.
MacOS X Hints Page detailing the URL Protocol Messaging
Apple's page, along with some helpful scripts
More helpful scripts

[ # ]
links to macosxhints data
Authored by: sjk on Dec 13, '03 10:17:21PM
Good suggestion! Which reminds me ...

In general it would be great if hint posters had a Mac OS X Hints "dropbox" for storing certain scripts, code fragments, patches, etc. for linkable reference/download instead of (or in addition to) it being part of the main hint text.

For example, while reading this hint last night I thought about how much shorter the first post would have been if parts of it (e.g. the code patches) were links to that content instead of inline text. And it would be trivial to download, without the copy/paste errors people often have.

There's really no additional site storage requirement since the data's already here... it would just be more convenient to access.

[ # ]
Create Palm Desktop memo entry from selection
Authored by: Fofer on Dec 12, '03 01:45:13PM
Okay, I have tinkered with all of the sample scripts here and combined what I feel is the best of the bunch. I wanted it to work in all applications, so I went with the "copy to clipboard first" approach. I also wanted the script to ask me for a Memo Title (rather than having it simply use the first few letters of my copied text.) Finally, I wanted it to show me a preview before sending it to Palm Desktop... while truncating any "extra long" memos that would cause the Preview window to be longer than my screen. Here is the fruit of my labor... maybe next time I'll go the extra mile and figure out how to post AppleScripts as clickable links. :-)

set contentsText to the clipboard as string
set contentsText to «class ktxt» of (result as record)
display dialog ¬
	"Enter a title for your Palm Memo: " default answer "" default button "OK"
set titleText to text returned of result
set titleText to «class ktxt» of (result as record)


if (count of contentsText) > 300 then -- truncate the search pattern before writing it to the window title
	set ContentsTextPreview to ((text 1 thru 300 of contentsText) & "…")
else
	set ContentsTextPreview to contentsText
end if
set confirmationMessage to "Preview of new Memo:

Title: " & titleText & "
" & ContentsTextPreview

display dialog the confirmationMessage ¬
	buttons {"Cancel", "Send to Palm Memo"} ¬
	default button 2 with icon 1 giving up after 20

set userChoice to the button returned of the result
if userChoice is "Send to Palm Memo" then
	
	tell application "Palm Desktop"
		activate
		try
			make new memo with properties ¬
				{title:titleText, contents:contentsText}
		on error msg
			display dialog msg
		end try
	end tell
end if


[ # ]
Create Palm Desktop memo entry from selection
Authored by: sp on Dec 13, '03 05:00:48AM

Very nice! Now if we could just send direct to the Palm with BT...



[ # ]
Feature Complete version: from selection, not pasteboard
Authored by: klktrk on Dec 13, '03 05:59:16PM
With help from the macscripters bbs, snippets from this hint page, and Nicholas Riley's LispMe importer (which showed me how to deal with setting categories), I've made the following script which grabs selected text from ANY frontmost app allows you to edit the title field, select a primary category and either just file it away in Palm Desktop, or open it in Palm Desktop for editing.

Enjoy!!!

Open this script in a new Script Editor window.

tell application (path to frontmost application as string)
activate
tell application "System Events"
set GUIenabled to get UI elements enabled
if GUIenabled = false then
display dialog "This script requires you to enable access for assistive devices in the Universal Access preference pane. You have not done so." buttons {"OK"} default button 1 with icon 0 giving up after 5
return
end if
set theProcess to item 1 of (every process whose frontmost is true)
set oldClipboard to the clipboard
try
tell theProcess to keystroke "c" using command down
delay 1 --give it time to update
set selectedText to (the clipboard) as string
set the clipboard to oldClipboard
on error msg
set selectedText to missing value
set the clipboard to oldClipboard
display dialog msg with icon 0
end try
end tell
if selectedText = missing value then
display dialog "Either the AppleScript GUI syntax does not work for this app, or the selection could not be converted to the appropriate format" buttons {"OK"} default button 1 with icon 0 giving up after 5
else if selectedText = "" then
display dialog "You need to select some text to put in the memo!" buttons {"OK"} default button 1 with icon 0 giving up after 5
else
if (count of selectedText) is greater than 20 then
set memoTitle to text 1 thru 20 of selectedText
else
set memoTitle to selectedText
end if
display dialog "Enter a title for your memo (20 chars max): " default answer memoTitle default button "OK"
set memoTitle to text returned of result
set memoTitle to «class ktxt» of (result as record)
if (count of memoTitle) is greater than 20 then
set memoTitle to text 1 thru 20 of memoTitle
end if

tell application "Palm Desktop"
set memoCategories to {}
repeat with thisCategory in categories
set memoCategories to memoCategories & {(name of thisCategory)}
end repeat
end tell

set categoryChosen to choose from list memoCategories with prompt "Select a category for this memo."
if categoryChosen is not false then
set memoCategory to item 1 of categoryChosen
else
set memoCategory to ""
end if


set contentsTextPreview to "This is your new memo:

Title: " & memoTitle & "
Category: " & memoCategory & "
Body: " & selectedText
if (count of contentsTextPreview) > 340 then
set contentsTextPreview to ((text 1 thru 300 of contentsTextPreview) & "…")
end if

display dialog the contentsTextPreview buttons {"Cancel", "Edit in Palm Desktop", "File in Palm Desktop"} default button 3 with icon 1

set userChoice to the button returned of the result
if userChoice is not "Cancel" then
tell application "Palm Desktop"
try
set newMemo to make new memo with properties ¬
{title:(memoTitle), contents:(selectedText), primary category:(category memoCategory)}
on error msg
display dialog msg
end try
if userChoice is "Edit in Palm Desktop" then
activate
show newMemo
end if
end tell
end if
end if
end tell

[ # ]
Create Palm Desktop memo entry from selection
Authored by: n1mie on Dec 31, '03 12:34:36AM

Looks like a great script ... but it doesn't work on this end. The error I receive is that when it goes to create the memo it says "The variable memo is not defined." So apparently it interprets the "make new memo of..." and doesn't understand the class memo and rather believes it is a variable. How do I fix this?

---
--Chip



[ # ]
Create Palm Desktop memo entry from selection
Authored by: rlesperance on Nov 21, '06 05:18:38AM

Hello,

I tried the last version of the script of this thread also and got this error message: «Impossible to tranfor «NewMemoName» in record type.» As there been a new version of your script ??


Robert



[ # ]