Skip to content

Instantly share code, notes, and snippets.

@mark05e
Last active June 17, 2024 19:12
Show Gist options
  • Save mark05e/95e7097de92149d3487d61eab6816efc to your computer and use it in GitHub Desktop.
Save mark05e/95e7097de92149d3487d61eab6816efc to your computer and use it in GitHub Desktop.
XML Notepad - Performs keyboard shortcuts to comment and uncomment nodes
; Author: mark05e, Gemini/Bard (Large Language Model by Google)
; Description: Performs keyboard shortcuts to comment and uncomment nodes within XML Notepad.
; - Ctrl + / or Ctrl + K: Simulates menu key press followed by "h" and "o" keys (for commenting)
; - Ctrl + Shift + / or Ctrl + Shift + K: Simulates menu key press followed by "h" and "e" keys (for uncommenting)
; References:
; - https://www.reddit.com/r/AutoHotkey/comments/xrfk3c/mouse_right_click_and_select_an_action_from/
; - https://github.com/microsoft/XmlNotepad/issues/396
; - https://www.autohotkey.com/boards/viewtopic.php?t=38761
; Hotkeys:
; - Ctrl + /
; - Ctrl + K
; - Ctrl + Shift + /
; - Ctrl + Shift + K
#Requires AutoHotkey v1.1+ <2.0
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
#SingleInstance ; Ensures only one instance of the script is running.
; Show message box on tray click
OnMessage(0x404, "AHK_NOTIFYICON")
AHK_NOTIFYICON(wParam, lParam, uMsg, hWnd)
{
if (lParam = 0x201) ;WM_LBUTTONDOWN := 0x201
{
DescriptionText =
(
This script performs keyboard shortcuts to comment and uncomment nodes within XML Notepad.
`n Ctrl + / or Ctrl + K: `n - Simulates menu key press followed by 'h' and 'o' keys (for commenting)
`n Ctrl + Shift + / or Ctrl + Shift + K: `n - Simulates menu key press followed by 'h' and 'e' keys (for uncommenting)
)
MsgBox, , Description, %DescriptionText%;
Reload
}
}
#IfWinActive ahk_exe XmlNotepad.exe ; Only listen to hotkey when XML Notepad is active window
; To comment xml nodes
^/:: ; Ctrl + / hotkey definition
^k:: ; Ctrl + K hotkey definition
Send, {Appskey} ; Send menu key
Send, h ; Send H key
Send, o ; Send O key
return
; To uncomment xml nodes
^+/:: ; Ctrl + Shift + / hotkey definition
^+k:: ; Ctrl + Shift + K hotkey definition
Send, {Appskey} ; Send menu key
Send, h ; Send H key
Send, e ; Send E key
return
#IfWinActive ; End of #IfWinActive block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment