Starting an AutoHotkey Script on Windows 11/10 Startup

Published by Nyau Wai Hoe - Updated on

AutoHotkey, often called AHK, is a mighty tool for Windows that lets you do a bunch of computer tasks automatically, like making keyboard shortcuts, managing windows, and a lot more. A lot of people who use AHK want to know how to make their scripts start by themselves when Windows starts.

In Windows 11 and 10, you’ve got two main ways to do this: using the Startup Folder or the Task Scheduler. Both are good, but they fit different needs. We’ll walk you through each method so you can get your AHK scripts up and running right when you start Windows.

How to Start AutoHotkey Script on Windows 11 10 Startup

Using the startup folder to start an AutoHotkey script on Windows startup

The Startup Folder in Windows is a special place where you can drop shortcuts to programs or scripts you want to run automatically when you log into your computer. It’s pretty simple to use.

Also see: Where is the Startup Folder in Windows 11/10 for All Users

Steps:

  1. Find your AHK script. Go to the folder where your .ahk file is.
  2. Right-click on your AHK script and pick “Create shortcut”. This makes a shortcut of the script right there.
  3. Hit the Windows + R keys together on your keyboard. This opens the “Run” dialog box.Create shortcut for autohotkey ahk script
  4. Type (or copy-paste) this in the “Run” dialog box:
    shell:startup

    Open startup folder via Run command in Windows 11

  5. Click “OK” or hit Enter. This takes you to the Startup folder for your account.
  6. Drag and drop the shortcut you made earlier into the Startup folder.Start an AutoHotkey script on Windows startup using startup folder
  7. Done! Your AHK script will now start every time you log into Windows.

For running your AHK script as admin on startup:

  1. Right-click on the AHK script shortcut in the Startup folder and choose “Properties”.
  2. Go to the “Shortcut” tab in the “Properties” window.
  3. Click the “Advanced” button down in the corner.AHK script advanced properties
  4. Check the “Run as administrator” box.Run autohotkey script on startup as administrator in Windows 11 10
  5. Click “OK” to close the Advanced Properties window, then “OK” again to close the Shortcut Properties window.
  6. Next time you start up, Windows will ask for permission to run the script with admin rights. Just say yes, and you’re set.

Notes:

  • If you want your script to start for every user, use shell:common startup in step 4. This opens the common Startup folder, and any shortcuts here run for all users.
  • If you move the original .ahk file, the shortcut might not work anymore. Make sure the original file stays put.
  • Be careful with scripts (or any program) that run as admin. Make sure they’re safe and not harmful.

Schedule an AutoHotKey script with the Task Scheduler

Task Scheduler gives you more options than the Startup Folder. You can set specific conditions, choose different triggers, and manage user permissions. This is great for scripts that need special permissions or need to run at certain times.

Steps:

  1. Hit the Windows key and type “Task Scheduler”. Click on it when it shows up.Open Task Scheduler Windows 11
  2. In the right pane, click on “Create Basic Task…”.Create a basic task in task scheduler
  3. Give your task a name like “My AHK Script Startup” and maybe a description. Click “Next”.Name the task to run ahk on startup
  4. Choose when you want the script to start:
    • Pick “When I log on” for personal scripts.
    • Or “When the computer starts” for system-wide scripts. Click “Next”.

    Set a task to run on computer startup or log on

  5. Choose “Start a program” and hit “Next”.Schedule a task to run autohotkey on startup
  6. Type or find the AutoHotKey executable path, then add your script’s path in the “Add arguments” box, like “"C:\Path\To\YourScript.ahk"“. Click “Next”.Start autohotkey script on Windows startup with Task Scheduler
  7. Check your settings and click “Finish” if everything’s okay.Finish setting up a task

Advanced options:

  • To run your script with admin rights, check “Run with highest privileges” in the task properties before finishing.How to start autohotkey script on Windows Startup as Administrator
  • You can also set the task to run at specific times or under certain conditions through the task properties.

Notes:

  • Task Scheduler can make sure your script runs with the needed permissions.
  • Always test your task after setting it up to make sure it runs correctly.

Related resource: How to Run Batch File Without the CMD Window

Troubleshooting common problems

Sometimes, even the best plans don’t work out. Here are some tips if you’re having trouble getting your AHK script to start with Windows:

If your script doesn’t start:

  • Check the paths: Make sure the paths to both the AHK executable and your script are correct.
  • Admin rights: Some scripts need admin rights. Check the properties of your shortcut or task.
  • Dependencies: Make sure any files or programs your script needs are where they’re supposed to be.

If your script starts but isn’t working right:

  • Add a delay: Use Sleep, DurationInMilliseconds in your script if it needs to wait for other programs to start.
  • Check for specific conditions: If your script depends on certain windows or programs, make sure they’re ready when your script runs.

Task Scheduler troubles:

  • Check task status: Look at the last run result and status in Task Scheduler for clues.
  • Review task history: Task Scheduler’s history can help you figure out what’s going wrong.
  • Conditions: Make sure any conditions you’ve set for the task (like running only on AC power) are met.

Wrapping up

AHK scripts are super handy, and you don’t need to compile them to run at Windows startup. Both the Startup folder and Task Scheduler methods work well, but if you need more control, go with Task Scheduler. If things don’t work as expected, check out the tips above for help.

Categories: Windows 10Windows 11

Nyau Wai Hoe
Nyau Wai Hoe is the Founder and Chief Editor of WindowsDigitals.com. With a degree in software engineering and over 12 years of experience in the tech support industry, Nyau has established himself as an expert in the field, with a primary focus on the Microsoft Windows operating system. As a tech enthusiast, he loves exploring new technologies and leveraging them to solve real-life problems.

Share via
Copy link