Mac OS X Leopard has a virtual desktop implementation called Spaces. I want to programatically detect which space the user is currently on.
Cocoa is preferable but AppleScript is acceptable if there's no other way.
I've seen a couple of AppleScript implementations, but the techniques they used seemed a bit too hacky to use in production code (one relied on causing and error and then parsing the error message to get the current space, the other interrogated the Spaces menu GUI)