Smart Desktop and Quick-Launch Icons For Discs and USB Drives with AutoHotkey

EDIT: This page describes the original AutoHotkey script; for information on the updated version, as well as a stand-alone program—so you don’t need to have AutoHotkey installed already—see the dedicated Smart Icons page.

As part of my recent drive to improve my Windows desktop, I’ve created a script for AutoHotkey to replicate the behaviour for removable-media icons in GNOME and on Macs.  In those operating systems, when a disc or USB drive is inserted into the computer, an icon for it is automatically added to the desktop; the icon is then deleted when the item is removed.  Since clearing my Windows desktop—removing the permanent icons for such drives, which would cause errors if the target was unmounted—I’ve concluded that it’s a shame Microsoft hadn’t included this useful little feature.

Fortunately, one particular page in AutoHotkey’s documentation demonstrates that a script can respond to a device change, allowing a function to check a series of specified drives for readiness, and add or delete a desktop icon for it as appropriate.

Then, as I was typing the last paragraph, I thought that it would be more useful (for me, anyway) to add the icons to the Quick Launch panel, because that’s visible almost all the time.  And, since using StartKiller, I have more than enough space for them there.

So now there are three user-specified variables:

smart-icons-for-mounted-media.ahk is released, as usual, under a GPLv3 licence.