AppleScript support

With version 3.0, CurrentKey Stats now responds to 12 new AppleScript commands. This is a feature that can be enabled in the new Background Services panel via Preferences.

These commands mean you can ask CurrentKey, programmatically, to do the following things:

– Go to a specific, assigned Room (the same as clicking a "Go to Room" option from the popover's dropdown).
– Get all assigned Room names and the active Room name.
– Get total time spent, today or yesterday, across all apps
– Get total time spent, today or yesterday, across a specific Room
– Get total time spent, today or yesterday, in a specific app
– Get total time spent, today or yesterday, in a specific app in a specific Room
– Get a list of all apps and their bundle names (the latter is needed for other app-specific commands)

There are also Room change alerts, which offer AppleScript support in the opposite direction (your script will get called with the new Room name). Go here for more on Room change alerts as well as many ideas on how to make use of all this power!

Below I will share what the actual AppleScript support for the above commands look like. But first, let me show you what the description of the commands are:

For any of these commands to actually work, you must first enable the feature in the Background Services panel:

In practice, here's a video of what these commands look like:

If you want to query about time spent in fullscreen, use "_fullscreen_" as the RoomName parameter. Similarly, if the getactiveroom command is sent while your fullscreen, the app will respond "_fullscreen_".

Here are slightly simpler one-liner examples of those commands:

tell application "CurrentKey Stats" to getactiveroom

tell application "CurrentKey Stats" to getassignedrooms

tell application "CurrentKey Stats" to gotoroom called "theNameOfAssignedRoom"

tell application "CurrentKey Stats" to appandbundlenames

tell application "CurrentKey Stats" to totaltime_today

tell application "CurrentKey Stats" to timeforapp_today withbundlename "com.apple.dt.Xcode"

tell application "CurrentKey Stats" to timeforappforroom_today withbundlename "com.apple.dt.Xcode" withroomname "coding"

tell application "CurrentKey Stats" to totaltime_yesterday

tell application "CurrentKey Stats" to timeforapp_yesterday withbundlename "com.apple.dt.Xcode"

tell application "CurrentKey Stats" to timeforappforroom_yesterday withbundlename "com.apple.dt.Xcode" withroomname "coding"

tell application "CurrentKey Stats" to timeforroom_today withroomname "coding"

tell application "CurrentKey Stats" to timeforroom_yesterday withroomname "coding"

and a couple new Commands:

tell application "CurrentKey Stats" to getactiveappname

tell application "CurrentKey Stats" to getactiveappbundlename