Using AutoHotKey to open a specific OneNote page
One of our internal OneNote users wanted a desktop shortcut to automatically open a specific page in OneNote. He keeps all his active "To Do" items on that page and wanted to quickly open that particular page. I pointed him at my batch file/Windows Task Service to do this and then Konstantine replied with an AutoHotKey script to perform a similar function. Here's what he had to say:
----
I’m a keyboard shortcut junkie so one more thing I did was to assign it to a keyboard shortcut. Some MS Keyboards have a bank of numbered buttons (above the Function Keys) that can be programmed to execute applications. Button #1 opens my tasks.
If you don’t have that kind of keyboard, you can also assign keyboard shortcuts to links on the desktop or create something in AutoHotkey.
Here is what I did with autohotkey
This script will:
- Launch onenote on Win+n, Win+n
- Launch todo Win+n, Win+t
- Launch my projects on Win+n, Win+p
Very convenient indeed…
*#n::
If winNPrefix = 1
{
IfWinNotExist, ahk_class Framework::CFrame
{
Run, onenote
}
else
{
ToggleRestoreMinimize("ahk_class Framework::CFrame")
}
winNPrefix = 0
}
Else
{
winNPrefix = 1
}
return
; -------------------------------------------------------------
; Onenote command handler for Win+n, Win+t
; -------------------------------------------------------------
*#t::
If winNPrefix = 1
{
Run, onenote /hyperlink onenote:///https://******.docs.live.net/************/myOnenotes/Todo.one#To-Do§ion-id={4243287F-E341-42B6-439C-72ACB33C10E0}&page-id={D4A34CFB-B69D-4B3F-B6B6-DE3DC6070E5C}&end
winNPrefix = 0
}
return
; ----------------------------------------------------------
; Restores or minimizes a window
; ----------------------------------------------------------
ToggleRestoreMinimize(in_winTitle)
{
WinGet mnmx, MinMax, %in_winTitle%
if (mnmx = -1)
{
; window is minimized restore it
PostMessage, 0x112, 0xF120,,, %in_winTitle%
WinActivate %in_winTitle%
}
else if (mnmx = 0 || mnmx = 1)
{
IfWinNotActive %in_winTitle%
{
WinActivate %in_winTitle%
}
Else
{
PostMessage, 0x112, 0xF020,,, %in_winTitle%
}
}
}
Pretty slick. I'm a big fan of AHK since it makes so many repetitive that much easier. Oh, and to get the URL Konstantine uses, see my original article.
Thanks for letting me post this, Konstantine!
Questions, comments, concerns and criticisms always welcome,
John
Comments
Anonymous
July 15, 2011
The comment has been removedAnonymous
December 08, 2011
@Grant ... I'd like to make the obvious readable; AHK is all about giving additional and advanced keyboard support to the advanced user.Anonymous
October 22, 2015
Thank you! I've been trying to do this for ages, but missed the /hyperlink. It seemed to work with a colon there for earlier versions of OneNote.