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

A script to send notes to a Bluetooth phone System
I recently got a Sony Ericsson T616 phone. It works perfectly with iSync. However, I like to be able to send notes to the phone, but iSync does not support it. To send a note to the phone, one can use BlueNotes to create a .vnt file then send through Bluetooth File Exchange (in Applications -> Utilities). This is a little bit tedious, so I create a python script, sendNote.py, to send a note directly from a terminal. This is the script:
#!/usr/bin/env /usr/bin/python
import sys,os

msg = ""
for l in sys.stdin.readlines():
  msg += l.strip()
  msg += " / "

homePath = os.environ["HOME"]

tmpf = open("%s/.BTNote.vnt" % homePath,"w")
if len(msg) < 250:
  msg = msg[:250]
else:
  msg = msg[:-3]
tmpf.write("BEGIN:VNOTEnVERSION:1.1nBODY:%snEND:VNOTE" % msg[:-3])
tmpf.close()

# Enter the next two lines as one long line, no spaces...
os.system("/usr/bin/open -a /Applications/Utilities/
 Bluetooth File Exchange.app %s" % tmpf.name)
Usage:
$ cat | python sendNote.py
My test note
You should use the Control-D keystroke at the end of the note you want to send. In the above example, a note with content "My test note" will be sent to the device you choose in Bluetooth File Exchange. It is also possible to wrap the script with a simple GUI. I wrote a simple application called BNSend.app to send notes through Bluetooth to my phone. The source code is included. My implementation depends on the open command and the python script, because I could not find a way to communicate with Bluetooth File Exchange via AppleScript. I would like to know if there is any way to talk to Bluetooth File Exchange with only AppleScript.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[22,533 views]  

A script to send notes to a Bluetooth phone | 9 comments | Create New Account
Click here to return to the 'A script to send notes to a Bluetooth phone' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to send notes to a Bluetooth phone
Authored by: BendiStraw on Apr 16, '04 10:22:26AM

I have the Nokia 3650 and I find that i can export stickies notes to .txt files and "send file" through the bluetooth file exchange and it shows up in my messages. Could this work on Motos? If not it seems like a pain.



[ Reply to This | # ]
Re: A script to send notes to a Bluetooth phone
Authored by: mtowber on Apr 16, '04 02:40:41PM

As a fellow T616 owner, I often find it usefull to create a "To Do" item in iCal. When you sync, a note is created in the phone's caledar/organizer. I'm not sure if there is a limitation on text length, though.

<^_^>



[ Reply to This | # ]
A script to send notes to a Bluetooth phone
Authored by: momerath on Apr 16, '04 07:48:09PM
The script doesn't work as is; the spaces in the bluetooth app name need to be escaped (and of course the space after 'Utilities' needs to be removed): os.system("/usr/bin/open -a /Applications/Utilities/ Bluetooth\ File\ Exchange.app %s" % tmpf.name) is what it should read.

[ Reply to This | # ]
A script to send notes to a Bluetooth phone
Authored by: cschin on Apr 16, '04 08:42:21PM
The line

tmpf.write("BEGIN:VNOTEnVERSION:1.1nBODY:%snEND:VNOTE" % msg[:-3])
should be

tmpf.write("BEGIN:VNOTE\nVERSION:1.1\nBODY:%s\nEND:VNOTE" % msg[:-3])
The
\
gets stripped.

[ Reply to This | # ]
How to send note via AppleScript
Authored by: hughescr on Apr 16, '04 08:38:49PM
tell application "Bluetooth File Exchange" to open alias ":path:to:the:file.vnt"
That pretty much works. Same as the
open -a
thing from the python script anyway.

[ Reply to This | # ]
How to send note via AppleScript
Authored by: cschin on Apr 16, '04 08:44:50PM

Thanks. I am the one who posts the original hint. Now, I can write a GUI version that only use AppleScript now.



[ Reply to This | # ]
How to send note via AppleScript
Authored by: whom on Sep 20, '04 12:13:30AM
Just save this script in the Users/username/Library/Scripts/ folder and make sure the script menu is running. To use it, just select text in an application (Safari, TextEdit, Mail...) and then run the script from the script menu. The text will be saved in a text file on the desktop and then opened with BlueTooth File Exchange to send the BT phone.
tell application (path to frontmost application as string)
	set procName to (path to frontmost application as string)
	set oldDelim to AppleScript's text item delimiters
	set AppleScript's text item delimiters to ":"
	set procName to procName's text items
	set i to the count of items in procName
	set procName to item (i - 1) of procName
	set AppleScript's text item delimiters to "."
	set procName to procName's text items
	set procName to item 1 of procName
	set AppleScript's text item delimiters to oldDelim
	activate
	try
		tell application "System Events"
			tell process procName to click menu item "Copy" of menu "Edit" of menu bar 1
			
		end tell
		delay 1
		set newClip to the clipboard
		if newClip is "" then error
	on error
		display dialog "I couldn't find text in the selection!  Or, the application doesn't accept this request for text." with icon stop
		error number -128
	end try
end tell
try
	set newClip to «class ktxt» of (newClip as Unicode text as record)
on error msg
	display dialog "Error processing the data..." & return & msg with icon stop
	error number -128
end try
set userDesk to (path to desktop as text)
set clip to 1
repeat
	set f to (userDesk & "clip" & clip & ".txt")
	try
		f as alias
		set clip to clip + 1
	on error
		exit repeat
	end try
end repeat

set fileNum to (open for access file f with write permission)
write newClip to fileNum
close access fileNum
tell application "Bluetooth File Exchange"
	activate
	open (a reference to (f as alias))
end tell


[ Reply to This | # ]
A script to send notes to a Bluetooth phone
Authored by: BTServer on Sep 15, '04 11:39:11PM

Hi all,

I have an early Preview Release available for Blue Tooth Server which (with Salling Clicker www.salling.com) allows you to transfer files from your mac via your phone or palm.

For example, with BTServer and Salling Clicker you can browse your iPhoto library on your phone and transfer images to your device to view full screen and save for later viewing.

You can use Applescript and build all sorts of apps which send mp3 files, documents, images etc, in fact any file to your phone from your mac. Then you can control these applescripts from your phone or palm and receive files from your mac without actually touching your cpu.

Anyway, if anyone is interested in taking a peek, please email me at btserver@wam.net.au and I'll provide you with further details and a download link. You will need a Bluetooth phone such as a P900 or a new Bluetooth Palm. You will also need to download Salling Clicker from www.salling.com - which is a great little app anyway :-)

Best regards to all,


Jeff
www.dotpod.net



[ Reply to This | # ]
A script to send notes to a Bluetooth phone
Authored by: jedik on Jul 28, '05 03:41:24PM

BlueNotes latest version (1.4b) features a command to directly sending the note to your phone (works with my T616) via BT File Exchange.

Tip -> if you can't run the app, just add ".app" to its name in Finder.

Cheers

---
:: Jedi Knight ::
-- Mac Rules! --



[ Reply to This | # ]