Using AutoHotKey to open a specific OneNote page

来源:互联网 发布:幻城h5源码 编辑:程序博客网 时间:2024/04/19 22:45

Using AutoHotKey to open a specific OneNote page

  • Comments2

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 mybatch 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 inAutoHotkey.

Here is what I did with autohotkey

This script will:

  1. Launch onenote on Win+n, Win+n
  2. Launch todo Win+n, Win+t
  3. 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&section-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

Blog - Comment List MSDN TechNet
Comments
  • #

    Um... You've been using Windows for how long?  Bill Gates should smack you all up-side your heads.

    Just right-click on the page tab, select "Copy link to page", and paste that into a new shortcut.   Done.

    I use OneNote for keeping track of just about everything now. I have lots of shortcuts on my desktop to open OneNote to specific locations. All of them work like a charm.

  • #

    @Grant ...  

    I'd like to make the obvious readable;

    AHK is all about giving additional and advanced keyboard support to the advanced user.