• Become a Power user Intro to AutoHotkey Intermediate AutoHotkey Intermediate Objects GUIs are Easy w/AutoHotkey Painlessly switch from V1 to V2

AHK Webinar- Simple and Associative Arrays in AutoHotkey

We had a great webinar on Arrays!  Here are links to the videosSimple and Associative Arrays in AutoHotkey

  • First hour video discussing below points
  • Second hour where we took a deep dive trouble-shooting an attendee’s script

Benefits of Simple and Associative Arrays in AutoHotkey

  • Speed – Objects are very fast!
  • Code maintenance / easier to update
  • Structured data
  • Easier to read / understand
    • Dot notation (names) can be very easy to read
    • Automatically group “variables” in a meaningful structure / Nesting deeper levels
  • Built-in functionality
  • Iterating over keys / values
  • Insert / Append to last
  • Remove / Remove last item
  • Count (Length)
  • Set / assign value (Index/Key – Value pair)
  • Retrieve / Lookup (Index/Key – Value pair)

AutoHotkey Merchandise-White Stress ballThings to Remember with Simple and Associative Arrays in AutoHotkey

  • Keys are not case sensitive The following results in one key-value pair: {ex:1,EX:2}
  • Keys are unique (If you have duplicates, only the last one will be kept)
  • Simple Arrays can not have “empty” spots
  • Associative Arrays are not, necessarily, ordered in the way you’d expect (when iterate over can seem out of order)
  • Simple arrays are sequential
  • Simple Arrays can be considered Associative Arrays where the Index is the key
  • You must declare the object before or during population
  • To “nest” an object, you must declare the Parent and sub-objects first too!
  • Although the same, Lexikos recommends using { } for Associative Array & [ ] for Simple Array
  • You do not need to save the object to iterate over it
  • Arrays are often returned from API calls in JSON
  • While Simple and Associative Arrays in AutoHotkey take a bit of getting used to, in the long run, they are great time savers!

Resources for learning Simple and Associative Arrays in AutoHotkey

Featured script

Pasting clipboard to p.ahkscript.org– great for collaborating with others!

Additional Resources

During the webinar a few other scripts were mentioned.  Here are the links that were shared:

MsgBox, % ObjectToString({"AHK" : [1, 2, 3], "Joe" : ["http://the-automator.com/"], "Jackie" : {"URL" : "https://jszapp.com/"}})

		return __IsNum(obj) ? obj : """" obj """"
	bool := obj.Length()
	res .= bool ? "[" : "{"
	for key, value in obj {
		res .= (!bool ? """" key """ : "  : "") ObjectToString(value) ", "
	return SubStr(res, 1, -2) (bool ? "]" : "}")

	if Num is Number
		return 1
	return 0


Arrays in AutoHotKey– A video walking through Arrays by a non-programmer

Arrays in AutoHotKeyArrays in AutoHotKey

While the AutoHotKey forum is awesome at providing great information and help, a lot of the content and people people that help solve my problems are so much further advanced than I, it can make understanding/following what they are saying difficult.  That in mind I thought I’d make a “simple” video explaining how to manipulate an Array in AutoHotKey.

I’ve been working with both Simple and Associative arrays lately and many examples I found in the forum, as well as in AutoHotKey help, were difficult for me to follow.

Thus I decided to take a crack at writing a tutorial from the non-programmer perspective. I’m sure some of my terminology is not correct (and some of it might flat out be wrong) but the below script works in the way that I describe in the video which I hope some other non-programmers will find helpful.

The script I work-through in the video can be downloaded from the first post here.

Intro to Objects in AutoHotkey – YouTube

Aug 3, 2012 Learn how to use arrays in autohotkey and the basics of classes. Ask questions so I know what to put in the next video! See the …

[AHK_L] Save/Load Arrays – Scripts and Functions – AutoHotkey …

Oct 7, 2012 Additionally, when most people start creating arrays in autohotkey, I doubt they typically make objects in the array called “Attributes” or …