Track Graphic Line Measurement Segments Using AutoHotkey Arrays

When Refreshing the MouseMeasure.ahk Invisible GUI Graphics Layer, AutoHotkey Uses a Simple Array of Associative Arrays to Track the Data

In my last blog (“Measure Multiple Line Segments with an AutoHotkey On-Screen Ruler“), I introduced multi-segment lines for estimating distances of non-linear routes. When refreshing the graphics to animate the moving line, all previously fixed segments need redrawing. Objects-based arrays provide the best method for tracking and regenerating these lines.

Each leg of the journey corresponds to a simple array element containing an associative array of data. The white box displays the key:value data saved in MyArray[4].

The difference between pseudo-arrays, simple arrays, and associative arrays can get confusing. For the novice AutoHotkey scriptwriter, unfamiliar Object-Oriented Programming (OOP) notation can make understanding the code even more difficult—especially if you attempt to learn OOP from online documentation.

You may think you need to choose between the traditional AutoHotkey syntax and OOP coding, but you don’t! AutoHotkey allows you to mix-and-match most OOP and classic AutoHotkey syntax—as long as you understand how they integrate.

Continue reading