lolvluser Posted March 3, 2009 Share Posted March 3, 2009 Hello to all here, i'm new to AutoIt and i hope that i'm posting to the correct forum. I encounter some problems on definening a multi-nested struct (with arrays of pointers to other structs). i think i searched the whole forum about a solution or hints, but either i was unable to find it, overlooked it or i simply does not yet exist (i found a simple example in a german formun on how to create a nested structure, but wasn't able or i do not understand on how to adapt it for my particulare purpose). what i'm trying to reach is, to have a table in which i define all from an application called windows and its associated ctrls that i have to test, fill the table with data run a loop on that table. in other words... As the main Application calls other command specific Windows i want to collect all that stuff and map it in one big table which i can work down in a loop. i post the c struct so you may have an idea what im searching for. i already spent a lot of time to get tagMainStruct and tagAppStruct together, but i didn't reach further. what i tried is, i defined pTabs[8] as addressholders (ulong_ptr) and then created each single tab struct and stored the returned value from DllStructCreate in that pTabs. same for the other struct. but when i retrieve the address from the array of pointers and pass this address to the DllStructGetData i get an error 6 or 7 (i don't remember rigth now) my questions are as follows: q1: can the below showed nested struct be created in AutoIt? q2: if yes, can someone give me a hint on how to do it? i hope its almost clear what i want and any help is much appreciated regards lo - level - user CODE #define nMainWnds 9 #define nTabCount 8 #define nButtonCount 5 /* Struct Declaration Section ========================================================= C Like Struct typedef struct { int nSize; // struct size : version identifier int nButtonId; // control id hwnd hButton; // ctrl handle char szCmd[1024]; // reserved char szArgs[256]; // reserved char szParams[256] // reserved }tagBtnStruct, *PTBTNSTRUCT; typedef struct { int nSize; // struct size : version identifier char szTabName[50]; // Tab caption hwnd hTab; // handle to the tabcontrol : type SysTabCtrl32 int iTab; // 0 based index of Tab short nButtonCnt; // ammount of Buttons PTBTNSTRUCT pButtons[nButtonCount]; // --> array of pointers to button struct : each pointer represents a button }tagTabStruct, *PTTABSTRUCT; typedef struct { int nSize; // struct size : version identifier char szWndName[50]; // application or window caption hwnd hWnd; // handle to window / application short nTabCount; // > 0 has a Tab Ctrl with nTabCount Tabs PTTABSTRUCT pTabs[nTabCount]; // --> array of pointers to tab struct : each pointer represents a tab with all the needed data }tagAppStruct, *PTAPPSTRUCT; typedef struct { int nSize; // struct size : version identifier tagAppStruct tAppStruct[nMainWnds]; }tagMainStruct, *PTMAINSTRUCT; tagMainStruct tMainStruct; tMainStruct.tAppStruct.pTabs = (PTTABSTRUCT)malloc(sizeof(tagTabStruct)*nTabCount) tMainStruct.tAppStruct.pTabs->pButtons = (PTBTNSTRUCT)malloc(sizeof(tagBtnStruct)*nButtonCount) ========================================================= */ Link to comment Share on other sites More sharing options...
weaponx Posted March 3, 2009 Share Posted March 3, 2009 There is no way to create a proper linked list in AutoIt. AutoIt lacks the ability to allocate memory on the fly, so every time you call DllStructCreate using the same variable name the old data is lost. The only way around this is to use an array to store all of the DllStructCreate handles, thereby defeating the purpose of a linked list. You are better off using other options. SQLite Nested Arrays Scripting.Dictionary array Link to comment Share on other sites More sharing options...
Ascend4nt Posted March 3, 2009 Share Posted March 3, 2009 (edited) One way is to create two arrays, both with the same amount of rows, have the 1st array have, besides the extra data, indexes into a. the previous item index and b. the next item index, then use the resultant index to access the other (main data) array. ReDim's would be necessary for both arrays as well as some maintenance code, and also a 'free node' index list. It's all very possible - the good algorithm books would probably give you an idea of how to create a linked list inside an array (or two in this case) Note that strings would best be done as they are in AutoIT, and moving it to a DLL call would involve using DLLStructCreate (or keeping a global one for faster use) and filling in the empty spots. *Edit: I just realized that the structure itself requires pointers in it - this would make it nearly impossible to do it as I recommended. Woops! Edited March 3, 2009 by ascendant My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
lolvluser Posted March 5, 2009 Author Share Posted March 5, 2009 hello weaponx && ascendant sorry for the late response. was doing other work and thanks for the confirmation and info. i was imaging that this were nearby impossible. i redefined the structdefinition and builded it a little bit less complex (without array of pointers) and created something like a mix of the things you both said. defined 2d arays for each structure definition in which one filed reprents the matching key for search purpose in the other arrays and one field which holds the data (pointers) returned by DllSctructCreate. so at least i can go trough the array and do the whole work from there. thanks again for the quick response. keep it real regards lo - level -user Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now