Sytone's Ramblings

The occasional posts of a guy who plays with technology.

Automating OneNote with AutoHotKey to be a Journal V1.1

2011-08-08 3 min read Productivity

Here is Version 1.1 of the script, it has some logging and I have tried to make the config simpler. 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. Also it now has the start as a ever increasing number so the tasks are soreted in the list for review time. 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. This is at the top of the file. OneNoteJournalSection := “onenote:< PATH TO SECTION STORING WEEKLY PAGES >Example: Using a Windows Live SkyDrive synced path. This will open the local copy of the OneNote file. OneNoteJournalSection := “onenote:https://wh7jutsd.docs.live.net/fac74a8d9c9b9a9c9d/%5e.Documents/My%20Journal/2011%20Journal.one” Code: [code lang=“autohotkey”] ; 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. ; V1.1 ; Added logging and set default to the ISO week. Play with number if you need to shift the week number. ; ; V1.0 ; - Inital Version to the World ; ; #SingleInstance force #NoTrayIcon ; ; Set the path below to the section containing the week pages. ; OneNoteJournalSection := “onenote:PATH_TO_SECTION_STORING_WEEKLY_PAGES” ; ; If you need to offset the week modify the offset below. ; JournalWeekOffset := 1 #j:: ; ——————————————————————————————— ; You should not have to modify anything below here.. I said should :) ; OneNoteUrl := OneNoteJournalSection . “#Week%20” FileRecycle, %A_ScriptFullPath%.log FormatTime, TimeString , , hh:mm:ss StringRight, WeekNumber, A_YWeek, 2 FileAppend, %TimeString% WeekNumber: %A_YWeek% `n, %A_ScriptFullPath%.log FileAppend, %TimeString% WeekNumber: %WeekNumber% `n, %A_ScriptFullPath%.log ;StringReplace, WeekNumber, WeekNumber, 0, ,All FileAppend, %TimeString% WeekNumber: %WeekNumber% `n, %A_ScriptFullPath%.log ; Allows you to offset the week if needed. ;FWIW… I found a solution for Win7 in this old thread: http://www.autohotkey.com/forum/topic991.html ;HKEY_CURRENT_USER\Control Panel\International\iFirstWeekOfYear WeekNumber := WeekNumber + JournalWeekOffset FileAppend, %TimeString% WeekNumber: %WeekNumber% `n, %A_ScriptFullPath%.log FileAppend, %TimeString% FullURL: %OneNoteUrl%%WeekNumber% `n, %A_ScriptFullPath%.log Run, %OneNoteUrl%%WeekNumber% ; Generate Date and Time Stamp FormatTime, TimeStringShort,, yyyyMMddHHmmss FormatTime, TimeStringLong,, dddd MMMM d, yyyy HH:mm:ss WinWaitActive, Week %WeekNumber% - Microsoft OneNote Sleep, 500 SendInput, ^{End} SendInput, ^{End} Sleep, 500 SendInput, {Enter}{Enter} SendInput, ———————————————– Sleep, 500 SendInput, {Enter} SendInput, ^1 SendInput, (%TimeStringShort%) %TimeStringLong% SendInput, {Enter} return ; Create all the weeks in the year in the current section. ; To use this Create a new section on OneNote ; Click in the title of the first untilted page. ; Press Shift+Ctrl+Win+Alt+J and it will make the pages. #+!^j:: ;Run, %OneNoteUrl% Loop, 52 { SendInput, ^n SendInput, Week %A_Index% Sleep, 300 } return [/code]