Autohotkey Autoinclude

Tags: Autohotkey

If you like Autohotkey, you probably have a lot of scripts you use or want to try out on a number of different computers. This leads to 2 challenges: running a lot of scripts separately is inconvenient (many separate AHK processes, many startup tasks), but combining them by hand is tedious at best. Also, you can sync scripts using OneDrive or Dropbox, but not all scripts may make sense (or even work) on all machines. In my case, I only use Outlook and Lync on my work laptop, so all the Outlook/Lync hotkeys only need to be active on that machine.

Enter Autoinclude. This is a very smart AHK script written by Scott Rippey that was published on Lifehacker some time ago. Follow the link for all the details, but what it basically does:

  • generate a single AHK script from a set of folders containing scripts
  • allows you to exclude specific folders on specific machines
  • execute that single script.

The only thing that you need to change in the AHK scripts that get included, is that you must add a comment on the first line with ";auto-execute" if you want to have auto-executing code in your particular script.

Setting up Autoinclude

You can read the Lifehacker post linked above to understand Autoinclude, so I will limit myself to a step-by-step instruction on how to set it up. This is what you do:

  1. set up a root folder for all your to-be-included scripts in a folder that is synced by OneDrive (or Dropbox or whatever else you prefer)
  2. On each machine, create a specific Autoinclude AHK script. What makes it specific for each machine is the list of folders inside the root folder that you want to have included (see code below).
  3. Set up a Windows startup task that points to this Autoinclude script (easiest method: add a shortcut to the Startup folder in your Start menu)

Done! Whenever your startup task activates, the Autoinclude script will generate a new script that includes everything you told it to include, and execute it. This is the section of Autoinclude.ahk where you set your folders:

StartUp = C:\Users\tijmenvdk\_SkyDrive\scripts\prod\Autoinclude
IncludeFolders =
(comments ltrim

Just to give you an idea of what my scripts root folder looks like:

Explorer folder view

As you can see, I have added a simple naming convention: the script name includes the assigned hotkey, where applicable.


You can download the script through Lifehacker, or you can grab my version here.