This is the best I got:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
AutoTrim, Off
ListLines, Off
SendMode, Input ; Recommended for new scripts due to its superior speed and reliability.
SetBatchLines, -1
#KeyHistory 0
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Include %A_ScriptDir%\Acc.ahk ; Comment out if you put Acc.ahk in the standard AutoHotkey library directory
noBackgroundXmlTemplate =
(LTrim
<?xml version="1.0"?>
<one:Page xmlns:one="http://schemas.microsoft.com/office/onenote/2013/onenote" ID="2.7.Z.E.R.O">
<one:PageSettings color="automatic"/>
</one:Page>
)
OnShellMessage(wParam, lParam)
{
global noBackgroundXmlTemplate
static GetAncestor := DllCall("GetProcAddress", Ptr, DllCall("GetModuleHandle", Str, "user32", "Ptr"), AStr, "GetAncestor", "Ptr")
if (wParam == 1)
{
WinGetTitle, title, ahk_id %lParam%
if (InStr(title, "OneNote"))
{
onApp := ComObjCreate("OneNote.Application")
winCount := onApp.Windows.Count
while (winCount--)
{
wnd := onApp.Windows[winCount]
if (wnd.SideNote == -1) ; VARIANT TRUE
{
if (DllCall(GetAncestor, "Ptr", wnd.WindowHandle, "UInt", 2, "Ptr") == lParam)
{
onApp.UpdatePageContent(StrReplace(noBackgroundXmlTemplate, "2.7.Z.E.R.O", wnd.CurrentPageId))
found := true
break
}
}
;ObjRelease(wnd) ; I never know the release policy with these IDispatch interfaces
}
ObjRelease(onApp)
if (found)
{
try
sosa := Acc_ObjectFromWindow(lParam)
catch
sosa := 0
if (sosa) {
for _, x in [[4,3,4,1,4,1,4,1,4,1,4,3,1]]
{
for _, val in x {
oldptr := sosa
try {
sosa := Acc_Children(sosa)[val]
} catch {
sosa := 0
break
} finally {
ObjRelease(oldptr)
}
}
if (sosa) {
sosa.accDoDefaultAction(0)
ObjRelease(sosa), sosa := 0
Sleep 100
Send, {Down}{Enter}
}
}
}
}
}
}
}
ShellUtils_Hook_Start()
ShellUtils_Hook_Start()
{
global shellHookMsg
if (shellHookMsg || !IsFunc("OnShellMessage"))
return
if (DllCall("RegisterShellHookWindow", "Ptr", A_ScriptHwnd, "UInt")) {
if (shellHookMsg := DllCall("RegisterWindowMessage", "Str", "SHELLHOOK", "UInt"))
OnMessage(shellHookMsg, "OnShellMessage")
else
DllCall("DeregisterShellHookWindow", "Ptr", A_ScriptHwnd)
}
}
ShellUtils_Hook_Stop()
{
global shellHookMsg
if (shellHookMsg) {
OnMessage(shellHookMsg, ""), DllCall("DeregisterShellHookWindow", "Ptr", A_ScriptHwnd)
shellHookMsg := 0
}
}
You need Acc.ahk in the same folder. The copy here matches what I downloaded from the original link before the service shut down.