AHK: What is an Array?

Arrays are a damn godsend. More specifically, they’re an easy way to deal with large lists. Why is this useful you ask? Imagine you want to run the same code on multiple items. The items could be numbers, letters, words, full sentences—anything.  By putting those things in a list, or an array, you can loop through hundreds, even thousands, of items with just a few lines of code.


So say, for instance, you wanted to rotate the letters in the alphabet up by a certain number. You could do that if/else coding all 26 letters by hand like I did last week. OR, you could create an alphabet array in AutoHotkey.

abcArray := [ “a”, “b”, “c”, “d”, “e”, “f”, “g”, “h”, “i”, “j”, “k”, “l”, “m”, “n”, “o”, “p”, “q”, “r”, “s”, “t”, “u”, “v”, “w”, “x”, “y”, “z” ]

A quick note:
The index is just an item’s position in the array. It can be used for easy access with [ ]. In this case, abcArray[1] = a,  abcArray[2] = b, abcArray[3] = c and so on. “a”, “b”, and “c” are called values.

The beauty of indexes is that they can be variables. That comes in handy when you’re changing the positions of values in your array. Here, I want everything shifted up so that abcArray’s 2nd letter is equal to rotatedArray’s 1st letter. Then I’m just adding 1 to each cycle of the loop to get positions for the rest of the alphabet.

The code below also uses a FOR LOOP to display the array at the end. Array FOR LOOPs  in AutoHotkey look a bit different. Here’s the template:

For index, value in Array
Do This with %index% or %value%

A breakdown of the code:


Which will result in:


While that may seem startlingly simple now, that little script took approximately 4 hours of me bashing my head against a wall because of 2 tiny mistakes.

Things to Check When Arrays Don’t Work



Once you’ve got a shifted alphabet, the Caesar Shift becomes significantly easier to script in AutoHotkey. An updated code is coming soon.

6 Replies to “AHK: What is an Array?”

  1. I form words from phrases like this “caters rinsed” via an application called “anagram master” and copy them while pasting(results} it to an app, i am seeking to know how i can paste the words .. filter it from the already posted words on the clip board(while not repeating what was first posted) an example is this, from these words “caters rinsed” you can come up with words like “drains,carted,cratered, etc” and when more words is added to “caters rinsed L O” this time around, there is an “L” and “O” and i will want to make new words with them.. I want to know how i can make the anagram master application search words, copy it to the clipboard without “drains,carted,crated” but with new words.. so it doesn’t duplicate when i next copy it to the clipboard ..

    More words are added after one minute.. they are the extra letters, so after searching the first set with my anagram master, they add just two letters supposedly as the extra letters and i search all the words with the anagram master. this time, there’ll be duplicates, this is what i don’t want the clipboard to post.. e.g. the words are “guide” you can sure form words like “dig,dug,guide” but when another letter is added to “guide” — guide “l” , it becomes “guide l” sounds like i am repeating myself here, but this is what happens with the anagram master application.. i enter “guide l” and search all the words from them while copying it to the clipboard, is there a way to make it not repeat the first words (dig,dug,guide) but rather make use of the ‘l’ which has been added? if you can create a script to help me do this, it will highly be appreciated, i need this badly 😦


    1. This sounds complicated–it’s hard to visualize without watching you do what you’re doing. But if you’re just looking to remove duplicates in the clipboard, there is an AutoHotkey workaround using Sort:


      If your anagram master separates the words with commas, just be sure to include that as your delimiter (otherwise it’ll default to the linefeed character). And make sure to use the U option, that’s what removes the duplicates. You could use the Clipboard as the variable and map the script to a hotkey script that can run continuously while the program is on.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: