Last active
November 13, 2017 12:22
-
-
Save db93n2/bb958c31da5359263e1ba33cf7fe7fd5 to your computer and use it in GitHub Desktop.
π© (autohotkey) - tray option to start your scripts when windows starts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start_with_windows(seperator="", menu_name="tray") { | |
global sww_shortcut, sww_menu | |
sww_menu := menu_name | |
if (seperator = "1") or (seperator = "3") | |
menu, % sww_menu, add, | |
menu, % sww_menu, add, Start with Windows, start_with_windows | |
splitPath, a_scriptFullPath, , , , script_name | |
sww_shortcut := a_startup "\" script_name ".lnk" | |
ifExist, % sww_shortcut | |
{ | |
fileGetShortcut, % sww_shortcut, target ;# update if script has moved | |
if (target != a_scriptFullPath) | |
fileCreateShortcut, % a_scriptFullPath, % sww_shortcut | |
menu, % sww_menu, check, Start with Windows | |
} | |
else menu, % sww_menu, unCheck, Start with Windows | |
if (seperator = "2") or (seperator = "3") | |
menu, % sww_menu, add, | |
} | |
start_with_windows: ;# action when tray item is clicked | |
ifExist, % sww_shortcut | |
{ | |
fileDelete, % sww_shortcut | |
menu, % sww_menu, unCheck, Start with Windows | |
trayTip, , Startup Shortcut removed, 5 | |
} | |
else | |
{ | |
fileCreateShortcut, % a_scriptFullPath, % sww_shortcut | |
menu, % sww_menu, check, Start with Windows | |
trayTip, , Startup Shortcut created, 5 | |
} | |
return | |
/* | |
[script info] | |
version = 2.1 | |
description = tray option to start your scripts when windows starts | |
author = davebrny | |
source = https://gist.github.com/davebrny/bb958c31da5359263e1ba33cf7fe7fd5 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
start with windows
Β
Β
usage
- add
start_with_windows.ahk
to one of the function libraries- add
start_with_windows()
to the auto-execute section of your script- click on "Start With Windows" in the tray to add or remove the script shortcut from the startup folder
Β
options
start_with_windows(1)
1 - add a separator before
2 - add a separator after
3 - add a separator before + after
(leave empty to add none)
the "Start With Windows" item is added to the "tray" menu by default. if you want to add it to a sub-menu inside the tray then pass that menu name to the second parameter
start_with_windows(1, sub_menu_name)