https://wiki.ruk.ca/w/index.php?title=Controlling_Plazer_with_Salling_Clicker&feed=atom&action=historyControlling Plazer with Salling Clicker - Revision history2024-03-28T11:48:06ZRevision history for this page on the wikiMediaWiki 1.28.0https://wiki.ruk.ca/w/index.php?title=Controlling_Plazer_with_Salling_Clicker&diff=2814&oldid=prevPeter at 20:59, 13 April 20062006-04-13T20:59:04Z<p></p>
<p><b>New page</b></p><div>[http://www.salling.com/Clicker/mac/ Salling Clicker] is an intriguingly powerful application that lets Bluetooth-enabled mobile phones interact fruitfully with a Macintosh.<br />
<br />
I thought it would be an interesting experiment to see if I could user Salling Clicker to control my [[Plazes]] status using the new Plazer application for the Mac. Turns out it was very easy. This is a step by step guide.<br />
<br />
===Step 1: Enable access for assistive devices===<br />
<br />
{| align="right"<br />
[[Image:Assistive.png|thumb|click to enlarge]]<br />
|}<br />
Because the OS X Plazer application doesn't support AppleScript directly, we've got to use [http://www.apple.com/applescript/uiscripting/ GUI Scripting] to control the application's menus. This is actually quite easy -- maybe even easier than if there was a Plazer AppleScript dictionary. <br />
<br />
GUI Scripting requires that "access for assistive devices" be turned '''on''' in the '''Universal Access''' System Preferences screen; open System Preferences, select Universal Access, and make sure that this checkbox is checked on.<br />
<br />
===Step 2: Set up the Plazer AppleScript===<br />
<br />
I'm assuming that you've already downloaded and installed [[http://www.salling.com/Clicker/mac/ Salling Clicker] and configured it for use with your mobile device. Don't bother going any further until you've done this; before proceeding, the '''Salling Clicker''' pane in System Preferences should say something like '''T610: Connected''' at the top (T610 in this case is the name of ''my'' device).<br />
<br />
Next, select the '''Phone Events''' tab within the Salling Click pane, and click on the little "hear" icon at the bottom of the pane and select '''New Script''' to create a new script:<br />
<br />
[[Image:Newscript.png]]<br />
<br />
Next, type the name of the new script in the field that appears -- something like "Set Plazes Status" is a good choice. Then highlight the new script, and select '''Edit in Script Editor''':<br />
<br />
[[Image:Editscript.png]]<br />
<br />
The '''Script Editor''' application will open. By default, new Salling Clicker scripts open with a template of AppleScript code that's useful because it contains hooks for all of the "events" that can happen -- incoming call, etc. In our case, it's the '''entering proximity''' and '''leaving proximity''' events that we're interested in -- these "fire" when your Bluetooth device enters and leaves the range of your Mac.<br />
<br />
The easiest thing to do at this point is to highlight all of the text in the template, delete it, and replace it with this AppleScript:<br />
<br />
<pre><br />
using terms from application "SEC Helper"<br />
<br />
on process entering proximity a_terminal<br />
--- Remember, this is just an example…<br />
tell application "SEC Helper"<br />
show screen message (bluetooth name of a_terminal) & " entered proximity!"<br />
end tell<br />
tell application "Plazer"<br />
activate<br />
end tell<br />
<br />
tell application "System Events"<br />
tell process "Plazer"<br />
tell menu bar 1<br />
tell menu bar item "Plazer"<br />
tell menu "Plazer"<br />
click menu item "Connected"<br />
end tell<br />
end tell<br />
end tell<br />
end tell<br />
end tell<br />
end process entering proximity<br />
<br />
on process leaving proximity a_terminal<br />
--- Remember, this is just an example…<br />
tell application "SEC Helper"<br />
show screen message (bluetooth name of a_terminal) & " left proximity!"<br />
end tell<br />
<br />
tell application "Plazer"<br />
activate<br />
end tell<br />
<br />
tell application "System Events"<br />
tell process "Plazer"<br />
tell menu bar 1<br />
tell menu bar item "Plazer"<br />
tell menu "Plazer"<br />
click menu item "Not Connected"<br />
end tell<br />
end tell<br />
end tell<br />
end tell<br />
end tell<br />
end process leaving proximity<br />
<br />
end using terms from<br />
</pre><br />
<br />
Click '''Compile''' in the Script Editor to make sure everything is pasted in correctly, then save the script and exit the Script Editor.<br />
<br />
===Step 3: Watch it Work!===<br />
<br />
That's it! You should find now that when your mobile device "enters proximity" -- i.e. comes within Bluetooth range of your Mac -- that the AppleScript fires, you see a message like this on the screen:<br />
<br />
[[Image:Enteredprox.png]]<br />
<br />
...and the Plazer application should start (if it's not running already) and automatically set your status to '''Connected''':<br />
<br />
[[Image:Connected.png]]<br />
<br />
Conversely, if you take your Bluetooth device out of range, your Plazes status should magically become '''Not Connected'''.<br />
<br />
It's amazing to watch once it's worked.</div>Peter