如何在“OneNote for Windows 10"中使用自动热键应用程序(不是 OneNote)? [英] How to make autohotkey work in "OneNote for Windows 10" app (not OneNote)?
问题描述
我正在尝试添加特定于程序的快捷方式,即仅在 OneNote 应用程序中使用的快捷方式,而不是打开应用程序本身的快捷方式.这是当前脚本的方式:
I am trying to add a program specific shortcut, i.e. a shortcut to be used inside OneNote App only, and not the short cut for the opening of app itself. Here is how the present script is:
#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 以在上述脚本中提及它.
But the above one works in OneNote desktop and not for the "OneNote for Windows 10" app (OW10A); how do I make it work for that store app? I am not able to find .exe for the store app to mention it in the above script.
推荐答案
您可以使用 #If- 或 #IfWinActive- 指令来创建上下文相关的热键和热字符串:
You can use the #If- or the #IfWinActive- directive to create context-sensitive hotkeys and hotstrings:
#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 Spy 获取有关程序窗口的详细信息.
Use Window Spy to get detailled information about the program 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
这篇关于如何在“OneNote for Windows 10"中使用自动热键应用程序(不是 OneNote)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!