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


Click here to return to the 'How to send note via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
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 | # ]