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.

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
  • 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? – Janac Meena Apr 21 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. – Anaksunaman Apr 22 at 2:18
  • Works! Thank you very much :) – Janac Meena Apr 22 at 23:48
  • You're welcome. Glad to help. =) – Anaksunaman Apr 23 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.