idpaterson / alfred-wunderlist-workflow

Unbelievably fast task entry in Wunderlist with due dates, reminders, and recurrence
297 stars 8 forks source link

Syntax to set the due date for the newly added task #40

Closed idpaterson closed 9 years ago

idpaterson commented 10 years ago

Adding due dates in Wunderlist takes at least several clicks, especially if the due date is neither today nor tomorrow. The ability to specify a due date when creating a task would be terribly useful.

Command Syntax

There are a myriad of options for natural language date processing, but for the sake of getting this feature out the door the options will need to be limited. Applescript supports locale-based date formatting out of the box, so at a minimum it should handle explicit dates like "12/31/2013" or "Dec 31 2013".

It would be nice to handle relative dates too though they would have to be locale-neutral (e.g. "+5" rather than "5 days from today"). The workflow localization can provide support for units other than days, for example "4w", "3m", "1y" corresponding to weeks, months, and years in English.

The syntax should not be overly verbose but it is important to ensure that it does not have to be overhauled if a similar feature is added in the future for scheduling reminders. Pending final decisions on the syntax.

Implementation

The process of parsing the date will vary depending on the syntax selected, so for now let's focus on the implementation after the point where a date is known.

  1. Insert task
  2. tab key to move selection to the top of the task list
  3. right arrow key to open the task details pane
  4. Inspect UI to test if title of task details pane matches the task
  5. up arrow if it does not match; user may have selected Add new items: Bottom of List in Wunderlist preferences, this will select the last item
  6. Use cliclick to tap the due date field
  7. Perform subtask: insert the date
  8. Use cliclick to tap the check button to confirm the due date
  9. left arrow to close the task details pane

    Insert the date

  10. Perform subtask: determine date format for the current locale
  11. Use cliclick to tap the left side of the due date field
  12. Send keystroke for the corresponding value in the target date
  13. Repeat steps 1-2 for each of the 3 date values

    Determine date format for the current locale

  14. Create a static date such as
set {theDate, theDate's month, theDate's day, theDate's year} to ¬
    {current date, 1, 2, 34}
  1. Get the short date string of theDate which in the US will be 1/2/34
  2. Split the string on non-numerics and determine the position of the day, month, and year
  3. Arrange target date components into an array in the same order

    Caveats

    Date formats

International date formats could be an issue. If Wunderlist changes the display of the date based on the locale (e.g. mm/dd/yyyy vs dd/mm/yyyy), AppleScript should be able to provide a date string in the current locale. Rather than extracting the day, month, and year it may be best to get the locale string matching whatever Wunderlist uses and split that into string components that can be inserted in whatever order the locale specifies.

Performance

The Wunderlist app appears to hesitate when switching between the three date component cells. This may be problematic for automation timing.

idpaterson commented 9 years ago

This will be handled much better in Python with #49