Skip to content

Instantly share code, notes, and snippets.

@davebrny
Created November 13, 2017 12:13
Show Gist options
  • Save davebrny/4b329b604ce742ba2581b6e691afea57 to your computer and use it in GitHub Desktop.
Save davebrny/4b329b604ce742ba2581b6e691afea57 to your computer and use it in GitHub Desktop.
(autohotkey) - tray option to run your scripts at startup
run_at_startup(seperator="", menu_name="tray") {
global ras_shortcut, ras_menu
ras_menu := menu_name
if (seperator = "1") or (seperator = "3")
menu, % ras_menu, add,
menu, % ras_menu, add, Run At Startup, run_at_startup
splitPath, a_scriptFullPath, , , , script_name
ras_shortcut := a_startup "\" script_name ".lnk"
ifExist, % ras_shortcut
{
fileGetShortcut, % ras_shortcut, target ; update target if script has moved
if (target != a_scriptFullPath)
fileCreateShortcut, % a_scriptFullPath, % ras_shortcut
menu, % ras_menu, check, Run At Startup
}
else menu, % ras_menu, unCheck, Run At Startup
if (seperator = "2") or (seperator = "3")
menu, % ras_menu, add,
}
run_at_startup: ;# action when tray item is clicked
ifExist, % ras_shortcut
{
fileDelete, % ras_shortcut
menu, % ras_menu, unCheck, Run At Startup
trayTip, , Startup Shortcut removed, 5
}
else
{
fileCreateShortcut, % a_scriptFullPath, % ras_shortcut
menu, % ras_menu, check, Run At Startup
trayTip, , Startup Shortcut created, 5
}
return
/*
[script info]
version = 3.0
description = tray option to run your scripts at startup
author = davebrny
source = https://gist.github.com/davebrny/bb958c31da5359263e1ba33cf7fe7fd5
*/
@davebrny
Copy link
Author

davebrny commented Feb 1, 2020

great! how to save the value after reload?

which value are you referring to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment