我正在尝试添加特定于程序的快捷方式,即仅在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在上面的脚本中提及它。
答案 0 :(得分:2)
您可以使用#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 Spy获取有关程序窗口的详细信息。
#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