Get String From Offset Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
lmstearn
Posts: 694
Joined: 11 Aug 2016, 02:32
Contact:

Get String From Offset

24 Apr 2017, 10:38

Hi there,
Suppose we setup a structure for a physical monitor thus with the well known:

Code: Select all

OffsetDWORD := 4
byteSize := A_IsUnicode ? 2 : 1
Physical_Monitor_size_single:= OffsetDWORD + byteSize * 128
VarSetCapacity(Physical_Monitor, Physical_Monitor_size_single, 0)
GetPhysicalMonitorsFromHMONITOR returns a handle, (0 for me but works) which is easily obtained.
But now we wish to grab the actual Physical_Monitor_size_single string which equates to something like

Code: Select all

buf := NumGet(Physical_Monitor, OffsetDWORD, "Str") ; we wish
;The longer version of above is 
Physical_Monitor := ""
Loop
{
buf := NumGet(Physical_Monitor, OffsetDWORD + byteSize * A_Index, "Char")
Physical_Monitor .= buf
} Until buf = "\0"
Is this the best approach?
Thanks. :)
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Get String From Offset  Topic is solved

24 Apr 2017, 17:04

NumGet wrote: Type
One of the following strings (defaults to UPtr if omitted):
UInt, Int, Int64, Short, UShort, Char, UChar, Double, Float, Ptr or UPtr
You might be interested in StrGet.

Good luck.

Edit:
Try this,

Code: Select all

Msgbox, % "\0"
What do you see?
User avatar
lmstearn
Posts: 694
Joined: 11 Aug 2016, 02:32
Contact:

Re: Get String From Offset

24 Apr 2017, 23:00

Helgef wrote:
NumGet wrote: Type
One of the following strings (defaults to UPtr if omitted):
UInt, Int, Int64, Short, UShort, Char, UChar, Double, Float, Ptr or UPtr
You might be interested in StrGet.

Good luck.

Edit:
Try this,

Code: Select all

Msgbox, % "\0"
What do you see?
I see a bad moon a-rising
(And no escape but the AHK default!)

Code: Select all

Msgbox, % "`0"
Thanks, missed Strget, no more worrying about null characters:
In Unicode, there is a character with a corresponding glyph for visual representation of the null character, "symbol for null", U+2400 (␀) -not to be confused with the actual null character, U+0000.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww and 207 guests