I have an AutoHotkey script and it should be started each time on Windows startup. For this purpose, it is located in %AppData%\Microsoft\Windows\Start Menu\Programs\Startup.

The problem is that my AHK scripts are associated with Sublime Text, not the AHK interpreter. (Typically, when I need to run a script, I open it in Sublime Text and then press F1. I have a special package for it.)

Hence, on Windows startup, this script is opened in Sublime Text instead of being started. Is there a way to start it?

Bad workarounds I'm aware of:

  • To associate .ahk files with AHK interpreter.
  • To convert .ahk file to .exe.
  • To start .bat or .ps1 file to start .ahk file. (That is, it is assumed that .ahk files are associated with Sublime Text, but .bat and .ps1 files are associated with the corresponding interpreters. I call this workaround "bad" because these file types are as well already associated with Sublime Text.)
  • 1
    Why don't you change the file association and try? Associate your .ahk files with AHK Interpreter and test it. If your script is launched on startup, you're good, if not, well, you can revert to Sublime Text if you want. AHK-to-exe would be a better option, IMO, but that's just me: Windows know what to do with .exe files, after all. Did you place a shortcut of your script in the Startup folder? Because that's the way to do it in shell:startup or shell:common startup (system-wide). Not copy the file itself, but its shortcut. EDIT: I suppose you've thought of, and discarded, Task scheduler? – Didier Mar 30 at 9:12
  • 1
    @Diader Yes, it is a good idea to use a shortcut, but I slightly improved it. Shortcut contents: Target = "C:\Program Files\AutoHotkey\AutoHotkey.exe" D:\path\to\the\script\script.ahk, Start In = D:\path\to\the\script (default). It seems it works for me. – john c. j. Mar 30 at 9:48
  • That's good enough for me, then! :-) – Didier Mar 30 at 10:04

Option 1:

In the Startup directory, create a shortcut with the following parameters:


"C:\Program Files\AutoHotkey\AutoHotkey.exe" D:\path\to\the\script\script.ahk

Start In:


Option 2:

You could also try to use Task Scheduler, but I haven't tried it myself.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.