XNeat Scripting Documentation
Sometimes you need to call win32 API that requires a pointer to struct, here comes the need to XNScript.Struct.
For example to create a win32 Point Struct
The first parameter is the field name
The second parameter is the field type which could be
Below are some examples that show the using of Win32 Struct
For example to create a win32 Point Struct
Dim XNScript
Set XNScript = WScript.CreateObject("XNeat.Core")
Dim Point
Set Point = XNScript.Struct
Point.add "x", "i32"
Point.add "y", "i32"
as you can see we first create an empty Struct. then we start adding fields using the Add method
The first parameter is the field name
The second parameter is the field type which could be
"ui32" for unsigned 32 bit
"ui16" for unsigned 16 bit
"ui8" for unsigned 8 bit
"i32" for signed 32 bit
"i16" for signed 16 bit
"i8" for signed 8 bit
"t" for ascii string
"w" for unicode string
for "t" & "w" fileds there exsits another parameter for the size
"ui16" for unsigned 16 bit
"ui8" for unsigned 8 bit
"i32" for signed 32 bit
"i16" for signed 16 bit
"i8" for signed 8 bit
"t" for ascii string
"w" for unicode string
Below are some examples that show the using of Win32 Struct
Dim XNScript
Set XNScript = WScript.CreateObject("XNeat.Core")
Dim User32
Set User32 = XNScript.LoadDll( "user32.dll" )
Dim Point
Set Point = XNScript.Struct
Point.Add "x" , "i32"
Point.Add "y" , "i32"
User32.GetCursorPos Point
MsgBox "Mouse x Position = " & Point.x
MsgBox "Mouse y Position = " & Point.y
This example gets the cursor position of the mouse using GetCursorPos API then display it.
Dim XNScript
Set XNScript = WScript.CreateObject("XNeat.Core")
Dim User32
Set User32 = XNScript.LoadDll( "user32.dll" )
Dim hWnd
hWnd = User32.GetForegroundWindow
Dim Caption
Set Caption = XNScript.Struct
Caption.Add "buffer" , "t", 1024
User32.GetWindowText hWnd, Caption, 1023
MsgBox Caption.buffer,0, "Foreground Window Caption"
In the above sample we see the using of ascii string and GetWindowText API to get the caption of the foreground window
Dim XNScript
Set XNScript = WScript.CreateObject("XNeat.Core")
Dim User32
Set User32 = XNScript.LoadDll( "user32.dll" )
Dim hWnd
hWnd = User32.GetForegroundWindow
Dim szPath
Set szPath = XNScript.Struct
szPath.add "buffer", "t" , 1024
XNScript.CallInWindow CLng(hWnd) , "kernel32.dll", "GetModuleFileName", 0, szPath, 1023
MsgBox szPath.buffer,0, "Foreground Window Path"
Another sample that shows the path of the Foreground Window.