Starting an AutoHotkey Script on Windows 11/10 Startup

Published by Nyau Wai Hoe - Updated on

AutoHotkey (AHK) is a scripting language for Windows that helps automate repetitive tasks, create hotkeys, manage windows, etc. Since they automate things, you might also want these AHK scripts to run automatically when Windows starts, so that you don’t have to manually start them every time you restart your computer.

In Windows 11 and 10, you can do this mainly through two methods: the Startup Folder method and the Task Scheduler method. Both are pretty efficient but serve different purposes. In this guide, we’ll explain each method so you can decide which one to use to get your AHK scripts running automatically at startup.

How to Start AutoHotkey Script on Windows 11 10 Startup

How to correctly use the startup folder to start an AutoHotkey script on Windows startup

The Startup Folder is a special place in Windows where you can put shortcuts to apps you want to run automatically when you log into your computer. This method is actually simple but often causes confusion. The following steps will show you how to correctly put the AHK script into the startup folder to let it auto-start on Windows startup.

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

    1. First, find your AHK script. Go to the folder with your .ahk file.
    2. Right-click on your AHK script and choose “Create shortcut”. This will make a shortcut of the script in the same folder.
    3. Now, press the Windows + R keys together. This opens the “Run” dialog box.Create shortcut for autohotkey ahk script
  1. In the “Run” dialog box, type (or copy-paste):
    shell:startup

    Open startup folder via Run command in Windows 11

  2. Click “OK” or press Enter. This will open the Startup folder for your user account.
  3. Now, just drag and drop the shortcut you made in step 2 into this Startup folder.Start an AutoHotkey script on Windows startup using startup folder
  4. That’s it. Your AHK script will now run every time you log into your Windows account.

If you want your script to run for all users, use the command shell:common startup in step 4. This will open the common startup folder, and any shortcuts placed here will run for all users on the system.

Also, if you move the original .ahk file, the shortcut might stop working. Keep the original file in its place.

Run your AHK script on startup as administrator

If you also need to run the AHK script with administrator’s privileges, there are some extra steps you need to take.

  1. In the Startup folder, right-click on the AHK script shortcut you added and select “Properties”.
  2. Go to the “Shortcut” tab in the “Properties” window.
  3. Click the “Advanced” button at the bottom-right of this window.AHK script advanced properties
  4. In the pop-up window, check the box labeled “Run as administrator”.Run autohotkey script on startup as administrator in Windows 11 10
  5. Click “OK” to close the Advanced Properties window, then click “OK” again to exit the Shortcut Properties window.
  6. On your next system startup, Windows will ask for permission (due to User Account Control) to run the script with admin rights. Allow this, and your script will start with elevated privileges.

Be careful when allowing scripts (or any app) to run as an admin. Make sure the script is safe and not actually harmful.

Schedule an AutoHotKey script to run on Windows startup using the Task Scheduler

The Task Scheduler is more flexible than the Startup Folder because it lets you set conditions, choose different triggers, and set user permissions. This is useful for scripts that need to run with admin rights or at specific times.

  1. Press the Windows key and type “Task Scheduler”. Click on the Task Scheduler app that 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. In the “Name” box, give your task a descriptive name, like “My AHK Script Startup”. You can also add an optional description. Click “Next”.Name the task to run ahk on startup
  4. For the trigger, you have a couple of choices:
    • Choose “When I log on” if you want the script to run every time you log into your computer. This is good for personal scripts that are user-specific.
    • Or, choose “When the computer starts” if you want the script to run as soon as the computer boots up, even before anyone logs in. This is useful for scripts that have system-wide effects or need to start before any user logs on.

    After choosing, click “Next”.Set a task to run on computer startup or log on

  5. For the action, choose “Start a program”. Click “Next”.Schedule a task to run autohotkey on startup
  6. In the “Program/script” box, type or browse to the AutoHotKey executable (usually in C:\Program Files\AutoHotkey\AutoHotkey.exe or similar).
  7. In the “Add arguments (optional)” box, type the path to your .ahk script in double quotes. For example:
    "C:\Path\To\YourScript.ahk"
    Click “Next”.Start autohotkey script on Windows startup with Task Scheduler
  8. Check your settings in the summary page, and if everything looks good, click “Finish”.Finish setting up a task

Other advanced options you might want to use

  • If you need your script to run with admin rights, before finishing the task creation, click on “Open the Properties dialog for this task when I click Finish”. In the properties dialog, under the “General” tab, check “Run with highest privileges”.How to start autohotkey script on Windows Startup as Administrator
  • Task Scheduler also allows you to run tasks at specific times, under specific conditions, or when specific events happen. You can set these under the “Triggers”, “Actions”, “Conditions”, and “Settings” tabs in the task properties dialog.

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

Some common issues

Although the methods above should usually get your AHK script to start automatically on startup, you might face some issues.

Script doesn’t run on startup

  • Make sure both the AHK executable and the script file paths are correct. If you’ve moved the script or the AutoHotKey installation, you might need to update the paths.
  • Some scripts need admin rights. Try setting the shortcut to run as admin through its properties window. Also, enable “Run with highest privileges” if you use the task scheduler method.
  • Your script might need other files or programs. Make sure they’re available and in the expected location when the script starts.

Script runs but doesn’t function as expected

  • Some scripts depend on other services or programs that start with Windows. You can add a delay to your script using the Sleep, DurationInMilliseconds command in AHK. For example, Sleep, 10000 will delay your script by 10 seconds.
  • If your script works with specific windows or apps, make sure they are available and in the expected state when the script runs.

Task Scheduler problems

  • In the Task Scheduler, you can see the last run result and the status of the task. This can provide clues if there’s an issue.
  • Task Scheduler keeps a history of when tasks are triggered and if they encountered any issues. This helps diagnose problems.
  • If you’ve set specific conditions for the task (like running only when on AC power), make sure those conditions are met.
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