0

I'm a beginner at AHK.

How can I disable the ctrl+t shortcut in OneNote using AutoHotKey?

My attempt so far at a script:

; use regular expressions for matching titles
SetTitleMatchMode,RegEx

#IfWinActive, ^ONENOTE.*
+insert::msgbox ctrl+t
#IfWinActive

I just put insert::msgbox but I would prefer if nothing at all happened.

1 Answer 1

3

Based on this Super User question, try simply using ^t:: in place of +insert::msgbox ctrl+t. Also note that the proper regular expression appears to (roughly) be (.*)OneNote(.*), as OneNote always seems to be included in the Window Title (ONENOTE.EXE is the executable name).

How can I disable the Ctrl + T shortcut in OneNote using AutoHotKey?

Generally speaking, the following script should block the Ctrl + T shortcut in OneNote:

; use regular expressions for matching titles
SetTitleMatchMode,RegEx

#IfWinActive, (.*)OneNote(.*)
    ^t::
#IfWinActive

Note that if you have this script running, nothing should happen when you press Ctrl + T. You can verify that the script is working by assigning ^t:: a message box:

; use regular expressions for matching titles
SetTitleMatchMode,RegEx

#IfWinActive, (.*)OneNote(.*)
    ^t::msgbox Sorry, Ctrl + T has been disabled!
#IfWinActive
4
  • Looks like that's a step in the right direction, but still I'm unable to even trigger the message box while in OneNote - so using ^t:: did not work. Any idea how I can debug this? Apr 21, 2019 at 21:43
  • I have updated my answer. In short, my guess would be that you are looking for the wrong string in your regular expression. Apr 22, 2019 at 2:18
  • Works! Thank you very much :) Apr 22, 2019 at 23:48
  • You're welcome. Glad to help. =) Apr 23, 2019 at 2:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .