objects: pointer to string

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

objects: pointer to string

10 Dec 2017, 05:47

- Sometimes Winapi functions need pointers to null-terminated strings, e.g. when setting the text of GUI items, or specifying filter information in a Common Item Dialog. Is it possible to point to array items (either to key names or to value text), or do you have to use variables? Even ... pseudo-arrays!?
- Anyhow, it would be interesting to know more about how AutoHotkey's arrays work.
- As an aside, this might be interesting re. this question:
objects: get correct case key name - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=31641
- Thanks for reading.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: objects: pointer to string

10 Dec 2017, 06:16

- Thanks Helgef, I checked if you were online before posting, it said you weren't, so this answer has come unexpectedly quickly, cheers.
- I actually did a fair bit of searching before posting. It's like with objects and SetCapacity, slightly facepalm. :facepalm:
objects: VarSetCapacity equivalent for array values - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=40045

Code: Select all

q::
obj := {}
obj.a := "hello"
MsgBox, % &obj "_" obj.GetAddress("a")
StrPut("E", obj.GetAddress("a")+2*2-2, 1)
StrPut("O", obj.GetAddress("a")+5*2-2, 1)
MsgBox, % obj.a
obj := ""
return
- When I create multiple keys and view the binary in the address space, the address pointed to by the object itself, and the strings, are all essentially next to each other, but I don't know where the names of the keys are kept, I might guess that there are pointers to key names within that binary.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: objects: pointer to string

10 Dec 2017, 07:00

I just poured my coffee, and checked in :wave:

The closeness of the addresses is likely due to the closeness of their allocation. The addresses of the keys are not accessible via built-in methods. The address of the object points to a memory location in which relevant data for the object is stored. It is like a struct. There was an example not long ago on how to get the count of an object's key value pairs, it works just like when you retrive values of the members of a struct. You could probably dig out the address of a key in a similar fashion, you have to look in the source code to see how it's layed out. Look for the mFields array.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, CrowexBR, mcd, rubeusmalfoy, ShatterCoder and 83 guests