如何让 autohotkey 在 "OneNote for Windows 10" 应用程序(不是 OneNote)中工作?

How to make autohotkey work in "OneNote for Windows 10" app (not OneNote)?

我正在尝试添加一个特定于程序的快捷方式,即仅在 OneNote App 中使用的快捷方式,而不是用于打开应用程序本身的快捷方式。 现在的脚本是这样的:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#IfWinActive, ahk_exe OneNote.exe

+Enter::
    Send, {(}!+d{)} 
return

但是上面的可以在 OneNote 桌面上使用,而不适用于 "OneNote for Windows 10" 应用程序 (OW10A);我如何让它适用于该商店应用程序?我找不到商店应用程序的 .exe 在上面的脚本中提及它。

您可以使用#If- 或#IfWinActive- 指令来创建上下文相关的热键和热字串:

#If WinActive("WinTitle ahk_class WinClass", "WinText", "ExcludeTitle", "ExcludeWinText")

#IfWinActive, WinTitle ahk_class WinClass, WinText, ExcludeTitle, ExcludeWinText

https://autohotkey.com/docs/commands/_If.htm

使用 Window 间谍获取有关程序的详细信息 windows。

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

SetTitleMatchMode, 2 ; Title can be part of the full title

#If WinActive("- OneNote ahk_class ApplicationFrameWindow", "OneNote")

    +Enter:: Send, {(}!+d{)}

    ; Here you can add more program specific shortcuts:
    ; ...

; Here you can add specific shortcuts for another program:

#If WinActive("‎- Microsoft Edge ahk_class ApplicationFrameWindow", "Microsoft Edge")

    +Enter:: MsgBox, You pressed Shift+Enter in Microsoft Edge

#If    ; turn off context sensitivity