AutoHotKey, Scripting

AutoHotKey: Productivity

October 5, 2016

Managing Tasks and Projects

I have used a number of productivity tools over the years from Thinking Rock to OmniFocus and have always been frustrated by not being able to access and edit my projects anywhere and on any device. For example, OmniFocus is probably my favourite tool by a long way and I have it on both my iPad and iMac but was unable to access it online or on Windows.

Eventually, I wound up using ASCII text files and dropbox to allow me to share, review and edit my projects on everything from my phone (Android), my iPad and my personal and work PCs (Windows).

My preferred method of managing projects and tasks is by using a fairly simply form of David Allen’s system, Getting Things Done (GTD). This combined with a deep and rather geeky pleasure using the Markdown format to write almost anything (including this) resulted in the following;

  • A single text file with a .md extension representing a logical area e.g. a project, a team or even a department.
  • In any file a Project always starts with the markdown heading notation # (hash/pound) e.g. # Release Procedures. Sub projects are simply marked using two or more # symbols and are always classed as being part of the preceding higher level project.
  • All task starts with “– [ ]” or “– [x]”. Empty if the task is pending and filled if it has a different status e.g. – [x] for completed. You can use other characters to signify other statuses but I try not to complicate things by doing this. Any other text is simply treated as comments or additional notes belonging to the preceding task or project.
  • The other main element is to use the @ symbol to add any additional notations e.g. @due(date/time) @done(date/time) @delegated(name) @start(date/time), etc.

What follows are the Autohotkey scripts I currently use to make using this system easier.

Create a New Task

#^n::Send, {home}- [ ]{space}

win + ctrl + n adds – [ ] at the start of the current line

:*:nt'::- [ ] `

Typing nt’ adds – [ ] at the current cursor position

:*:- [ ::- [ ] `

Typing – [{space} simply adds ]{space} completing the checkbox and adding a space so you can just start typing the task description.

Add Task Detail

Then there are a number of scripts that help add the additional detail;

:*:a’::
:*:asn':: gui, add, combobox, vAssigned, Murray|name|name|name gui, add, button, default xm gPRD_Assignee, Set Assignee gui, show, autosize center, Select Assignee return

PRD_Assignee:
  gui, submit
  send @assigned(%Assigned%)
  gui destroy
  return

Typing a’ or asn’ displays a dialog allowing you to select a name from the dropdown list. It adds @assigned(selectedName) at the cursor. Just pressing enter without selecting an option adds @assigned()

:*:c'::
:*:con'::
  inputbox, context, Enter Context, Context
  send @context(%context%)
  return

Typing c’ or con’ displays a simple input dialog where you can type a context and it then adds @context(context) at the cursor. Just pressing enter adds @context().

:*:d'::
:*:due'::
  inputbox, dueDate, Enter Due Date and or Time, Due Date/Time
  send @due(%dueDate%)
  return

Typing d’ or due’ displays a simple input dialog where you can type the due date and it then adds @due(date) at the cursor. Just pressing enter adds @due(). All the date time scripts work for this dialog so you can use cdd to select a date and format from the Choose Date Dialog.

:*:dl'::
:*:del'::
  inputbox, delegatedTo, Enter delegate name, Name
  send @delegated(%delegatedTo%)
  return

Typing dl’ or del’ displays a simple input dialog where you can type the name of the person the task has been delegated to. It then adds @delegated(name) at the cursor. Just pressing return adds @delegated().

:*:dn'::
:*:done'::
  inputbox, done, Done Date, Done
  send @done(%done%)
  return

Typing dn’ or done’ displays a simple input dialog where you can type the date the task was completed and it then adds @done(date) at the cursor. Just pressing return adds @done(). All the date time scripts work for this dialog so you can use cdd to select a date and format from the Choose Date Dialog.

:*:prj'::
  inputbox, projName, Enter Project Name, Project Name
  send @project(%projName%)
  return

Typing prj’ displays a simple input dialog where you can type the project the task belongs to and it then adds @project(projectName) at the cursor. Just pressing return adds @project(). I only really use this if I’m quickly adding tasks to my inbox list and want to note the project it applies to. I plan to extend this a bit in the future to make it more useful.

:*:pri'::
  gui, add, combobox, vPriority, High|Medium|Low
  gui, add, button, default xm gPRD_Priority, Set Priority
  gui, show, autosize center, Select Priority
  return

PRD_Priority:
  gui, submit
  send @priority(%Priority%)
  gui destroy
  return

Typing pri’ displays a input dialog where you can select a priority status from a drop down list it then adds @priority(selectedPriority) at the cursor. Just pressing enter adds @priority().

:*:rpt'::
  inputbox, repeat, Set Repeat Interval, Repeat every
  send @repeat(%repeat%)
  return

Typing rpt’ displays a simple input dialog where you can type a description of how the tasks repeats e.g. @repeat(Every Tue at 1400). Just pressing enter adds @repeat().

:*:sta'::
  inputbox, status, Enter Status, Status
  send @status(%status%)
  return

Typing sta’ displays a simple input dialog where you can type a status e.g. @status(On Hold) or @status(75%). Just pressing enter adds @status().

:*:str'::
:*:start'::
  inputbox, startDate, Enter Start Date and or Time, Start Date/Time
  sendinput @start(%startDate%)
  return

Typing str’ or start’ displays a simple input dialog where you can enter a date e.g. @start(2016/10/01). Just pressing enter adds @start(). All the date time scripts work for this dialog so you can use cdd to select a date and format from the Choose Date Dialog.

Toggle Task Status

Another script I use allows the quick toggling of any task between – [ ] and – [x].

#!d::
  ; Use the clipboard to grab the current line
  Clipboard =
  Send {END}
  Send {SHIFTDOWN}{HOME}
  Send ^c
  ClipWait
  task := clipboard

if(IsTask(task)) {
  ; It is a task, now toggle the check
  if(IsNotDoneTask(task))
   send % SetTaskDone(task)
  else if(IsDoneTask(task))
    send % SetTaskNotDone(task)
  Else {
    ; in case there is some other status in use replace it with Done
    task := "- [x]" SubStr(task, InStr(task, "]",,1) + 1,StrLen(task))
    send %task%
    }
  }
  Send {SHIFTUP}
  Send {END}
  return

Alt + win + d toggles between – [ ] and – [x] replacing any custom status with a done status. e.g. – [H] becomes – [x] .

As mentioned above I’m going to add code to append/remove a @done() tag with the current date & time and the ability to move completed tasks to an archive or daily completion/review log.

There are a couple of support functions e.g. IsTask(string) that are needed as well;

IsTask(value) {
  ; Look for the start of a task checkbox at the start of the line
  if(SubStr(value, 1, 3) = "- [")
    return True
  Else
    return False
}

IsDoneTask(value) {
  ; look for a done checkbox
  if(SubStr(value, 1, 5) = "- [x]")
    return True
  Else
    return False
}

IsNotDoneTask(value) {
  ; Look for a not completed checkbox
  if(SubStr(value, 1, 5) = "- [ ]")
    return True
  Else
    return False
}

SetTaskDone(value) {
  ; simply replaces empty checkbox with done checkbox
  return % StrReplace(value, "- [ ]", "- [x]")
}

SetTaskNotDone(value) {
  ; Replaces a done checkbox with an empty one.
  return % StrReplace(value, "- [x]", "- [ ]")
}

There are a couple more scripts that allow the quick adding of tasks to an inbox project/file and extending the Project selection popup with a hierarchical list of current projects. These are also where I start using ini files to manage settings and preferences and I’ll cover them in a separate post.

Note

Some of these functions work even on indented lines as AutoHotKey automatically trims whitespace from the start and end of lines. This can be confusing sometimes and can be turned off, just not in these scripts. This is one of the reasons I use all the productivity scripts as a separate compiled executable.

AutoHotKey, Scripting

AutoHotKey: Time and Date

September 20, 2016

I use a simple set of scripts that allow me to enter dates in a range of formats. Day.Month.Year, Month/Day/Year, Year-Month-Day with a range of separators. This is done using the standard script below and changing the <key> and Date/Time format String.

:*:<key>::
FormatTime, timeString,,<timeFormat> Send %timeString% Return

For example I have the following setup;

key FormatString Output
ddd yyyy.mm.dd 2016.09.17
sdd dddd mm Monday 19
ldd dddd, dd mmmm yyyy Friday, 17 September 2016
sdmy dd/mm/yyyy 19/09/2016
ddmy dd-mm-yyyy 19-09-2016

and so on.

To make it easier to select any date in any of the formats I use I added this little script.

#+d::
:*:cdd::
  Gui, Add, MonthCal, vDate
  Gui, Add, DropDownList, vFormatString, yyyy.MM.dd||yyyy.MMM.dd|dddd dd MMM yyyy|dddd dd|yyyy/MM/dd|yyyy/MMM/dd|dd/MM/yyyy|dd/MMM/yyyy|yyyy-MM-dd|yyyy-MMM-dd|dd-MM-yyyy|dd-MMM-YYYY
  Gui, Add, Button,Default Section gDateTime_OK,&OK
  Gui, Add, Button,ys gDateTime_Cancel,&Cancel
  Gui, Show
  Return

DateTime_OK:
  Gui,Submit
  FormatTime, timeString, %Date%, %FormatString%
  Send %timeString%
  Gui, Destroy
  Return

DateTime_Cancel:
  Gui, Destroy
  Return

datedialogSelecting Win + Alt + d or typing cdd pops up a small calendar dialog  and allows you to select a date and a format from the drop-down list, it’s then added where the cursor is.

 

Save

Save

Save

Save

AutoHotKey, Scripting

Taming Windows

September 19, 2016

Computers are very good at dull, repetitive tasks, humans less so. I am slightly less tolerant of the dull and repetitive than average so get great enjoyment from eliminating the dull where I can and enhancing the rest as much as possible with tricks, scripts and shortcuts.

Over the (many) years I have worked with computers I have used a number of scripting and automation technologies and thought I would share some of the scripts and techniques in case they are of interest or helpful.

AutoHotKey

One of the most powerful tools for windows is AutoHotKey. If you are not familiar with it, AutoHotKey is a Macro tool that allows you to really customise and automate your computer.

From the simplest replacement e.g. every time you type ys# it is replaced with

Yours sincerely
Murray

to more complex scripts that, for example, allow you to manage text based todo lists or enter any date and how you want it formated by selecting it from a small popup dialog that appears when you type Win + Alt + d or cdd (Choose Date Dialog).

I’ll write up the scripts, why I use them and how they work in what are, to me, logical sections. There is lots of help online and on the AutoHotKey site (http://www.autohotkey.com).

If you have any questions or comments please feel free to add them below the relevant post.

Productivity

Setting Outlook 2010 mail categories using AutoHotKey

August 2, 2012

If you haven’t looked at AutoHotKey (http://www.autohotkey.com) I strongly recommend you do, it is one of the best windows automation/scripting tools I have used. I would find my PCs much harder to use and my job more tedious without it.

I currently have a number simple hot keys and text expansions setup to;

  • Add any of my signatures in emails
  • Expand a number of common phrases e.g. bsm# -> business systems mangers
  • Expand initials to correct names
  • Type commonly used emails from a simple mnemonic
  • Correct common spelling mistakes
  • Swap Selected text with contents of the keyboard

and many more. I use Outlook 2010 at work and make use of the tagging and categorising of emails to manage my tasks. One annoyance of this is that if you gend up with to many categories you always have to open the All Categories dialog to select any not on the recently used list on the right mouse click.

To address this I have added a new little script as below.

#c::
    if ErrorLevel
        return
    else
        SetTitleMatchMode 2
        IfWinExist, Unread Mail
        {
            WinActivate, Unread Mail
            SendInput {Shift}+{F10}
            SendInput ta
            WinWait Color Categories
        }
    return

This allows me to select any email using the mouse or keyboard and hit WIN->C and start typing the name of the category. Not a big thing but it makes like easier. WIN->at would achieve the same thing of course but I prefer this option as it can be used from anywhere.

Windows, Windows XP

Getting Applications to work with Windows Networking and Proxies

December 11, 2011

It seems there are as many ways to set up a windows network and proxy server as there are engineers setting them up. In my current place of employment I have found a number of apps including DropBox simply do not work across the proxy server, even with all the relevant details and passwords.

I have, however, found a solution in CNTLM (cntlm.sourceforge.net). This little utility can be run or installed as a service as desired and will provide support to any apps that have not implemented NTLM or have done it badly.

You install the application, setup your proxy server and account details and point applications to it instead of your corporate proxy server. Hey presto, DropBox springs into life.

Please note that while Cntlm can support http tunnelling this may annoy your sys-admins, a lot. I personally use it to provide SOCKS and NTLM support to apps that otherwise won’t talk to the internet over our proxy.

It is working a treat.