A few days ago i got the spaceNavigator as a present. Although i use both operating systems OSX and Windows i spent most of the time in OSX. Unfortunately the spaceNavigator is not supported widely by mac programs. Therefor i started developing a little cocoa app that makes use of the spaceNavigator. My goal is to use the spaceNavigator in Mac OSX as an extended input device to control different daily tasks.
There are some different ways to automate tasks in OSX. For this first ‘test’ app i used mostly Applescript.
Applescript is an powerful and easy language to run simple tasks.
Let me explain an simple task that selects the next track in iTunes:
tell application “iTunes”
next track
end tell
Off course selecting a next track is not that useful, although it gives a good view of the simplicity of the basics.
Ok, thats nice we can perform different tasks by writing simple applescript, but how to run them so they become useful?
This is where the 3Dconnexion SDK comes in. The 3Dconnexion sdk supply’s three little sample apps, i’m using the “3DxValuesCocoa” app. This simple app shows you how to use the provided 3DconnexionClient.framework. For more information look at: http://www.3dconnexion.com/support/sdk.php
i modified the app so it can use an appleScript. Basically i add the folowing code:
if(state->axis[2] > zUp){
if (pauze == 0){
NSLog(@”bigger than %d”, zUp);
NSDictionary* errorDict;
NSAppleEventDescriptor* returnDescriptor = NULL;
NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:zUpText];
// next track
// set sound volume to sound volume + 2
returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
[scriptObject release];
if (returnDescriptor != NULL)
{
// successful execution
if (kAENullEvent != [returnDescriptor descriptorType])
{
// script returned an AppleScript result
if (cAEList == [returnDescriptor descriptorType])
{
// result is a list of other descriptors
}
else
{
// coerce the result to the appropriate ObjC type
}
}
}
When the application is selected the functions will not be called, only when the applications runs on the background, all function or better sad, applescripts are called.
Rotate left and right access the workspaces when it reaches the value 200:


June 21st, 2009
5 Comments at "3Dconnexion spaceNavigator and the power of Applescript"
Nice idea. I’m also got one as a gift, and apart from a few obvious apps that it was designed for, I’m wondering how to make use of it. At the moment I use the light to remind me which machine my keyboard is connected to (I have two machines connected via the USB hub in my monitor) but it would be much nicer if I could have it tell me things like if I have voicemail (via phlink).
This app will make the experimentation much easier! Just need some good ideas now! Moving between spaces seems like a good start.
Sounds really good! I hope you will keep developing the program and everybody will finally be able to take real advantage of their SpaceNavigators. Zoom in, zoom out in different programs, Logic control (buttons changes the active track, rotate changes the gain, pan-tilt zooms in and out, etc), iTunes control (navigation in cover flow mode, volume up and down, next/previous track, play/pause…), Firefox control, many things in Finder… you get the point! Good luck with it!
Excellent start at making this device more usable outside of 3D apps that it supports. I’ll be following your progress on this, and hopefully have something of my own to add to it. Thanks so much!
This application no longer works under snow leopard unfortunately. I’d love to get the source code so that I can update this to work in snow leopard and convert it to a launchd daemon so it can run in the background from boot. Please email me if that is a possibility.
I also would very much like to have an updated version that will work on Snow Leopard. Thanks for making the spaceNavigator a LOT more useful!
Comment Now!