Update on 2013-06-06: Readded class script.THX, polyethene for messing this post!
I know about HotKeyIt's Struct() script, but remaining with AHK Basic I could not use it, and (to tell the truth) I did (and do) not understand entirely, why it is working, so I never tried.
Things changed with AHK 1.1. Curious I started to play around with the new class syntax and after some times of struggle I got an idea of the new possibilities for scripting with AHK. So this is my attempt to design a class for structures. It does not have any advantages over HotKeyIt's function other than "better" readability. It supports "plain" structures only, it is less complete (but it's easy to comlete the WinTypes object), it may be less comfortable and may have less performance, but someone may find it usefull anyway or may take it as an example of the class syntax:
APIStructures.ahk (example of some predefined structures):
The class script is somewhat tested on WinXP and Vista (x86 / U32) and Win 7 (x64 / U64). It may be buggy, so if you find some bugs, report them here, please.
Update 2011-07-24[*:3h48yj5e]Windows data types are completed (at least I hope so)[*:3h48yj5e]Changed class name to "DllStruct" (some reminiscence of AutoIt)Update 2011-08-01[*:3h48yj5e]Added support for set/get fields with multiple occurrences as a whole passing/as an array[*:3h48yj5e]Changed sample scriptUpdate 2011-08-02[*:3h48yj5e]Fixed bug in Init() method (THX Lexikos)[*:3h48yj5e]Added support for named occurrences (e.g. "LONG rcWindow;".[*:3h48yj5e]Changed sample scriptUpdate 2011-08-28[*:3h48yj5e]Editorial revisionUpdate 2011-11-14[*:3h48yj5e]Added basic type alignment (hopefully like the VC/VC++ compilers will do by default)[*:3h48yj5e]Added type of fields which names are preceded with "*" will become "UPTR"Update 2011-11-22[*:3h48yj5e]Added structure padding[*:3h48yj5e]Added option "Align n;" to set the alignment from within the "StructString" parameter.Update 2011-12-07[*:3h48yj5e]Fixed broken structure initialization with NULL.Update 2011-12-09[*:3h48yj5e]Fixed erroneous alignment (hopefully).Update 2012-01-21[*:3h48yj5e]Added optional alignment for embedded structures.[*:3h48yj5e]Added option "pad n;" for explicit padding.[*:3h48yj5e]Changed error handling to provide more useful informations.[*:3h48yj5e]Changed structure parser to ignore linebreaks.[*:3h48yj5e]Changed APIStructures.ahk sample script.