Hold Button To Execute Script, On Button Release Another Script?

I have a small script that uses curl to control a relay box via http calls. I want to be able to press a button in the GUI and have one curl command execute and when I release the button have another curl command execute.

I have this working with 2 separate buttons, one with each curl command but I’m not sure what do so from here. What I’m doing is using the relay box for panning a camera head so I want to be able to hold the “pan left” button down and have it pan but as soon as I release the button it will stop the panning. This way would be more intuitive then a button for ‘start pan left’ and another for ‘stop pan left’.

Thanks,

Brad

Okay so I found a sample that I need. I have Mouse Down and Mouse Up checked in the NSButton Inspector. I’ve added the following lines in the script but the buttons appear to be dead.

output1 is my button name.

on mouse down theObject event theEvent
	if the name of theObject is equal to "output1" then
		do shell script "/usr/bin/curl http://admin:12345678@192.168.100.28/SetIO?p61=1"
	end if
end mouse down

on mouse up theObject event theEvent
	if the name of theObject is equal to "output1" then
		do shell script "/usr/bin/curl http://admin:12345678@192.168.100.28/SetIO?p61=0"
	end if
end mouse up

You might want to try quoting the URLs:

do shell script "/usr/bin/curl " & quoted form of "http://admin:12345678@192.168.100.28/SetIO?p61=1"

I must have had a typo somewhere because I noticed the script wasn’t compiling (turning blue) when I would save it. I started over with a new project and retyped it all and now it works as expected.

Brad