Usage
Used in conjunction with External function to retrieve an integer value from memory.
Syntax
var = PeekInteger(<address>, <number_bytes>)
Parameters
<address>
: Unsigned variable, address to start reading from.<number_bytes>
: Integer constant, number of bytes to read (1, 2, or 4).
Return value
var
: 32-bit integer or UNSIGNED for a pointer. If the function fails, script execution stops and no error handling is possible.
See also
Examples
DIM ahandle as UNSIGNED
...
handle = PeekInteger(ahandle, 2)
'Script returning the mouse coordinates with the use of PeekInteger and External
'Define memory address
dim addx as unsigned
dim addy as unsigned
'allocate memory starting at addx for the coordinates
'addx will contain the X coordinate
addx = allocate(8)
'addy will contain the Y coordinate
addy = addx + 4
'Call the function in a loop
repeat
'address for structure addx is a parameter for GetCursorPos
a = External("user32.dll", "GetCursorPos", addx)
if a <> 0 then
'Read 4 bytes from memory at address addx (x position)
pos_x = PeekInteger(addx, 4)
'Read 4 bytes from memory at address addy (y position)
pos_y = PeekInteger(addy, 4)
'Display result
mes$ = "Cursor X is at : " + str$(pos_x) + "\nCursor Y is at : " + str$(pos_y)
msgframe(mes$, 1)
pause 1
endif
until i = 100
'the function loops for 100 seconds