1. Home
  2. Windows
We are reader supported and may earn a commission when you buy through links on our site. Learn more

How to change the icon for an AutoHotKey script on Windows 10

We’ve covered quite a few tricks for Windows 10 that involve an AHK script. AutoHotKey is one of the easiest ways to automate simple things on Windows 10. The better you are at writing a script, the more polished you can get it to look.

By default, all AHK scripts have the same icon; the green H that appears in the system tray to indicate a script is running. There’s nothing wrong with the icon but if you have a lot of scripts running, the icon makes it difficult to see which one is active, and which isn’t. A simple way around this is to change the icon for an AutoHotKey script. Here’s how.

Change icon for AutoHotKey script

In order to change the icon for an AutoHotKey script, you first need an icon. You can use a JPG or a PNG file and convert it to an icon file. Just make sure you aren’t using a copyright-protected image.

You can run an AHK script from any folder and the icon file doesn’t need to be in the same folder, however, make sure the icon file is placed in a folder where it does not risk being deleted by accident.

Open the AHK script that you want to add an icon to in Notepad. Enter the following code at the top, just before the script begins.

Code

I_Icon = path-to-icon\file.ico
IfExist, %I_Icon%
Menu, Tray, Icon, %I_Icon%
;return

Example

I_Icon = C:\Users\fatiw\Desktop\AHKscript.ico
IfExist, %I_Icon%
Menu, Tray, Icon, %I_Icon%
;return

Save the change to the file and then run the script, or reload it if it is already running. The icon in the system tray will update so that the default H is replaced with the icon that you set in the file.

When you right-click the script, you will still see the usual options you get when you right-click an AHK script. The icon can be changed any time you like but you will need to update the path to the icon in the script and rerun it.

If you share this script, the icon won’t go with it. The script is in its uncompiled form which means it will work fine on your system where the paths that you give it all exist. If you share the script with someone and want the icon to be included, you are going to have to compile the script or provide instructions on how to get the icon to appear. It’s nothing too hard but whoever you send the script to will have to edit it a bit before it can be used.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.