Applescript Proxy Help - Controlling your Macintosh with a Arduino

After searching High and Low for Tinker.it and their Applescript proxy program, I have located it and posted it on my website

http://www.bandster.us/ASPROXY.zip

This is a zip copy of the original software, with the items also extracted

here is the applescript code.

// Applescript Proxy test
// Skip to the next song on itunes every 10 seconds
void setup() {
Serial.begin(9600);
}

void loop() {
Serial.print("A");
delay(10000);
}

The original program was titled "asproxy02.dmg"

Jonathan
www.macgeek.com

So, this lets you run arbitrary AppleScripts from your Arduino!

Cool! Thanks for letting us know. I had no idea this existed.

For those who want to see the readme without downloading:

Tinker.it! <info (at) tinker.it>

AppleScript Proxy
control your Mac from Arduino

Version 0.2, 2007-04-26
Made in Italy

American Style Disclaimer

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

When you decide to use this software, you do it on your own risk. Using this software might cause damage to your software and even to your hardware.

Keep in mind this is a beta version, which means you could encounter problems while using it. Although it works pretty well

Use
AppleScript Proxy reads characters sent by an Arduino board and executes an AppleScript mapped to it.
This can be used to let Arduino control you apple mac computer. Since most of the apps in your mac support some basic AppleScript commands then the possibilities are endless.
The Application was compiled as an Universal Binary so it should work with both PPC and Intel Mac.

Plug an Arduino board and run the app. The serial port connected to arduino should already show up on the list at the top of the window.
select the communication speed, that depends on the Serial.begin() command you used in your arduino code. the default speed
is 9600.

to add a mappin press the + button and specify a character (case sensitive!) and type an applescript fragment. press the test button to try out the script. when you click on + again or anywhere on the list of mappings the data is save.

You can save and retrieve mappings into .axp files. there are just xml files so you can open them in any text editor.

Sorry if these instructions are simple but I'm waiting for your comments on how to expand it.

License
This app is freeware, it was written to build quick experience prototypes, it works for us and that's enough :slight_smile:
You can use it as long as you don't start charging money to other people for this.
If you want to distribute this app with a product you should check with us.
We are available to make customised version of this app for any project you might have in mind.

Credits
This application was written by Massimo Banzi <info (at) tinker.it>
It contains DictionaryViewer and XMLDictionary by Kevin Ballard kevin@sb.org

Hi,

Is there any chance that either of you still have the file? The link to the zip file is dead.

Thanks for your help,

Grant

There you go...

The license says its freeware - so help yourself.

Si.

I've used SerialPort X with much success:
http://mysite.verizon.net/vzenuoqe/MacSoft.html

Mike,
can you supply some help in how serial x listens to a open port and on a trigger letter runs a applescript?

I was TOTALLY baffled by it!

Thanks

Jonathan

First install the SerialPort x.osax file, then copy this code and paste it into the applescript editor window and run it.
You will get a list of ports, you click on one and the message is sent to it.

property thePorts : {} --Attached Serial Ports

-- List the Serial Ports & select one from list

set thePorts to serialport list
set arduinoPort to choose from list thePorts

-- this opens the port and resets the arduino
set arduino to serialport open arduinoPort bps rate 9600 data bits 8 parity 0 stop bits 1 handshake 0
if arduino is equal to -1 then
	display dialog " could not open port "
else
	delay 1
	-- send something to the port
	set xstr to "Test" & return
	serialport write xstr to arduino
	delay 1
	
	display dialog "Just sent the string " & (xstr) & " to the arduino " & return
	-- note this next bit will reset the arduino
	serialport close arduino
end if

Look at the ADTest for an example of reading bytes from the arduino.

Try this for reading the arduino and doing a command in AppleScript

set arduinoPort to "/dev/cu.usbmodem1d11"
-- this opens the port and resets the arduino
set arduino to serialport open arduinoPort bps rate 9600 data bits 8 parity 0 stop bits 1 handshake 0
if arduino is equal to -1 then
	display dialog " could not open port "
else
	repeat -- repeat forever
		-- wait until something is sent
		set bytesIn to 0
		repeat until bytesIn is not equal to 0
			set bytesIn to serialport bytes available arduino
		end repeat
		set cmd to serialport read arduino for 1
		set cmds to cmd as string
		-- display dialog "Command recieved = " & cmds
		
		if cmds is equal to "1" then
			display dialog "Command 1 recieved"
		end if
		if cmds is equal to "2" then
			display dialog "Command to quit recieved"
			exit repeat
		end if
		
		
	end repeat -- of the forever repeat
	-- note this next bit will reset the arduino
	serialport close arduino
end if

If you want you can include the port selection part of the previous script but this just uses the fixed port name I get.