Simply add a shortcut of your script in the Windows ‘Startup’ folder.
Three ways to get there:
1– In Windows Explorer, go to %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
(for current user startup list) or %ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Startup
(for every user startup list)
or
2– Open Windows’ Run application (Windows + r) write shell:startup
(current user) or shell:common startup
(every user) in the edit field and click on the ‘ok’ button.
or
3– Start > Programs > Startup (old Windows versions)
In AutoHotKey you can access this folder with the Built-in Variables %A_Startup%
(current user) or %A_StartupCommon%
(every user)
To create the (current user) shortcut automatically from your script, use the following line:
FileCreateShortcut, %A_ScriptFullPath%, %A_Startup%\shortcutname.lnk
To do the same for all users, use this line instead:
FileCreateShortcut, %A_ScriptFullPath%, %A_StartupCommon%\shortcutname.lnk
(in the case of having a file with the same name in the folder, the file would be overwritten)
ps: Win10 blocks scripts in startup with AHK running as admin… read the comments of this post for extra info.