Sytone's Ramblings

The occasional posts of a guy who plays with technology.

Automating OneNote with AutoHotKey to be a Journal

2011-01-18 2 min read Productivity

I use OneNote more and more in my daily work. I wanted to have the ability to make a journal function accessible from anywhere.

**Goal :**To be able to hit Win+J and have OneNote open the right page and date and time stamp the entry.

Outcome: When I hit Win+J it opens OneNote at the right week (I have one page per week with the heading of Week 1, Week 2, …, Week 52) goes to the end of the entry and inserts a line and then makes a check box with the date and time as the value. This allows me to simplify my weekly review as it is hard to miss a checkbox with a date in it. I also created a second function Ctrl+Shift+Alt+Win+J which makes 52 pages in OneNote (You need to have the section open that you want the pages created in) for the journal.

Configuration: You will need to modify the OneNote Url in the code. ; Set the path below to the section containing the week pages and ensure it ends with #Week%20 OneNoteUrl := “onenote:< PATH TO SECTION CALLED 2011 Journal >/2011%20Journal.one#Week%20

; Goes to the week in OneNote for the journal.
; Created by Jon Bullen (http://blog.sytone.com)
; Leave a comment on the site if you have issues.
#SingleInstance force
#NoTrayIcon
#j::
  ; Set the path below to the section containing the week pages and ensure it ends with #Week%20
  OneNoteUrl := "onenote:&lt; PATH TO SECTION CALLED 2011 Journal &gt;/2011%20Journal.one#Week%20"
  StringRight, WeekNumber, A\_YWeek, 2
  StringReplace, WeekNumber, WeekNumber, 0, ,All
  ; Hack to match Outlook... Works for 2011...
  WeekNumber := WeekNumber + 1 Run, %OneNoteUrl%%WeekNumber%
  WinWaitActive, Week %WeekNumber% - Microsoft OneNote Sleep, 500
  SendInput, ^{End}
  SendInput, ^{End}
  SendInput, {Enter}{Enter}
  SendInput, -----------------------------------------------
  Sleep, 500
  SendInput, {Enter}
  SendInput, ^1
  SendInput, !+D
  SendInput, {Space}
  SendInput, !+T
  SendInput, {Enter}
return

; Create all the weeks in the year in the current section.
#+!^j::
  Loop, 52 { SendInput, ^n SendInput, Week %A\_Index% Sleep, 100 }
return