UI Interaction

Version:
0.2

Introduction

Interacts with the Wunderlist UI for reading and modifying data.



Groups

Accessing Data in Wunderlist

Group members:

getIndexOfListNamed

Finds the index of the specified list in the list table

getListInfo

Loads some basic information about all of the visible lists in Wunderlist.

getListInfoForActiveList

Loads information about the currently selected list in Wunderlist.

getTaskInfoForFocusedList

Loads info about the tasks in the currently visible task list

invalidateListInfoCache

Ensures that the next time the list info is requested, it will be reloaded from the UI rather than the cache.

 

Application Interactions

Group members:

activatePreviousApplication

Activates the original frontmost application before the script was started.

activateWunderlist

Causes Wunderlist to become the active application.

assignWunderlistToAllDesktops

Uses the Dock.app menu to make Wunderlist visible on all desktops, which is necessary for the list info to load reliably.

 

Navigating Wunderlist

Group members:

focusInbox

Moves focus within the app to the Inbox list.

focusListAtIndex

Moves focus within the app to the specified list.

focusPreviousList

Returns focus to the last list viewed prior to navigating lists.

focusTaskInput

Switches keyboard focus to the task input field.

setWindowViewNormal

Switches to the "Normal" view in Wunderlist where both the list and tasks are visible.


Functions

activatePreviousApplication

Activates the original frontmost application before the script was started.

activateWunderlist

Causes Wunderlist to become the active application.

assignWunderlistToAllDesktops

Uses the Dock.app menu to make Wunderlist visible on all desktops, which is necessary for the list info to load reliably.

focusInbox

Moves focus within the app to the Inbox list.

focusListAtIndex

Moves focus within the app to the specified list.

focusPreviousList

Returns focus to the last list viewed prior to navigating lists.

focusTaskInput

Switches keyboard focus to the task input field.

getIndexOfListNamed

Finds the index of the specified list in the list table

getListInfo

Loads some basic information about all of the visible lists in Wunderlist.

getListInfoForActiveList

Loads information about the currently selected list in Wunderlist.

getTaskInfoForFocusedList

Loads info about the tasks in the currently visible task list

invalidateListInfoCache

Ensures that the next time the list info is requested, it will be reloaded from the UI rather than the cache.

setWindowViewNormal

Switches to the "Normal" view in Wunderlist where both the list and tasks are visible.


activatePreviousApplication


Activates the original frontmost application before the script was started.


activateWunderlist


Causes Wunderlist to become the active application.


assignWunderlistToAllDesktops


Uses the Dock.app menu to make Wunderlist visible on all desktops, which is necessary for the list info to load reliably.

Deprecated

in version 0.2


focusInbox


Moves focus within the app to the Inbox list.

on focusInbox()
Discussion

Uses the keyboard to move focus within the app to the Inbox list. The Inbox list is a good reference point because it is always at the top of the lists table.

The procedure for accessing the Inbox from any point in the app is as follows:

  1. ⌘+f Begin a search

  2. Perform a search that will probably not return results and will not be too distracting. 3 space characters works fine.

  3. ⌘+n Navigate to the Inbox, focused on the Inbox list


focusListAtIndex


Moves focus within the app to the specified list.

on focusListAtIndex(
    listIndex)
Parameters
listIndex

The numerical one-based index of the desired list.

Discussion

After calling focusInbox as a reference, simply use the arrow keys to move focus to the desired list.

The procedure for focusing a specific list is as follows:

  1. Focus the Inbox list

  2. Press the down arrow as necessary until the list is focused


focusPreviousList


Returns focus to the last list viewed prior to navigating lists.

Discussion

Conveniently, Wunderlist goes back to the previously viewed task when the search term is cleared. This means that we can call focusInbox or even focusListAtIndex, add tasks, and then go return Wunderlist to its original view state.

The procedure for returning to the previous list is as follows:

  1. ⌘+f Return to the search input

  2. Press the delete key to clear the search, Wunderlist will switch back to the previously viewed list

  3. ⌘+n Move focus out of the search box into the task list

  4. ⇧+tab Return focus to the list table


focusTaskInput


Switches keyboard focus to the task input field.

Discussion

In certain views it is necessary to use the New Task shortcut twice because the first time switches the UI to the Inbox list.

The procedure for returning to the previous list is as follows:

  1. ⌘+n Focus the task input, or in some cases focus the Inbox

  2. ⌘+n For good measure in case the previous command focused the Inbox


getIndexOfListNamed


Finds the index of the specified list in the list table

on getIndexOfListNamed(
    theListName)
Parameters
theListName

Text exactly matching the name of a list

Return Value

The integer index or missing value if no list with the specified name exists

Discussion

Returns a one-based index of the list with the specified name, or missing value if the list does not exist


getListInfo


Loads some basic information about all of the visible lists in Wunderlist.

Return Value

A list of records in the ListInfo format described below, sorted in the order displayed in Wunderlist.

Discussion

Wunderlist exposes a small amount of information about the lists that can be retrieved by traversing the UI. This information includes the name of each list, its number of tasks.

Unfortunately, the number of tasks returned is undefined when there are no tasks in a list. Wunderlist does not set the value of the task count label to zero, nor does it hide the label in a way that is detectable by AppleScript. The value in the label appears to change in an undefined way, so unfortunately at this time the task count is unreliable.

The list info is cached as specified by listCacheInSeconds to optimize repetitive access of the list, as with an Alfred Script Filter.

The keys lists and listsUpdatedDate in the default settings.plist are used to track the lists state.

ListInfo record

listName

The display name of the list

taskCount

The number of uncompleted tasks in the list

listIndex

The one-based index of the list in the UI

listPosition

The position of the list in the UI in {x, y} format

getListInfoForActiveList


Loads information about the currently selected list in Wunderlist.

Return Value

A records in the ListInfo format

Discussion

The active list is highlighted in the Wunderlist UI, but finding it with UI traversal is not straightforward. In order to find which list is selected, the Rename Selected List menu option is required. It creates an editable text element that is easy to isolate with AppleScript.

From the text element the name of the list can be retrieved. This allows the proper result from getListInfo to be returned.

See


getTaskInfoForFocusedList


Loads info about the tasks in the currently visible task list

Return Value

A list of records in the TaskInfo format described below

Discussion

Loads some basic information about all of the items in the visible list in Wunderlist. Unfortunately, due to limitations in the GUI access used to load task info, this will only include tasks that are visible in the window.

TaskInfo record

taskName

The display name of the task

dueDate

The due date of the task or missing value if not set

taskIndex

The one-based index of the task

invalidateListInfoCache


Ensures that the next time the list info is requested, it will be reloaded from the UI rather than the cache.


setWindowViewNormal


Switches to the "Normal" view in Wunderlist where both the list and tasks are visible.