Skip to content

Instantly share code, notes, and snippets.

@Pagliacii
Created February 9, 2021 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pagliacii/fafccc9b1f692070dccb9a5b67bad8a8 to your computer and use it in GitHub Desktop.
Save Pagliacii/fafccc9b1f692070dccb9a5b67bad8a8 to your computer and use it in GitHub Desktop.
Add custom menu items to the AHK tray menu, which lets you can edit the current running script with your favored editor.
#NoEnv ; Recommended for performance and compatibility with future AutoHotKey releases.
SendModeInput ; Recommended for new scripts due to its superior speed and reliability.
#Persistent ; Keeps a script permanently running (that is, until the user closes it or ExitApp is encountered.
insertMenuItemsBeforeStandard()
;
; This functions inserts your menu items before the standard menu
;
insertMenuItemsBeforeStandard() {
Menu, Tray, NoStandard ; Removes original menu
Menu, Tray, Add, Edit via Sublime Text 3, editViaST3 ; Creates a new menu item
Menu, Tray, Add, Edit via VSCode, editViaCode ; Creates a new menu item
Menu, Tray, Add ; Creates a separator line
Menu, Tray, Standard ; Puts original menu back
Menu, Tray, Default, Edit via Sublime Text 3 ; Sets default item and makes its font bold
}
editViaST3() {
; Edit the current running script with sublime text application by the subl command.
; The Hide option will hide the black cmd window.
Run subl "%A_ScriptFullPath%",,Hide
}
editViaCode() {
; Edit the current running script with editor specified by full path.
; The Hide option will hide the black cmd window.
Run "X:\path\to\code.cmd " "%A_ScriptFullPath%",,Hide
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment