XNeat Scripting Documentation
This is a quick tutorial that will show you by examples various ways to call win32 API using XNeat.
It is recommended not to spik any example as they depend on each other.
Example: Calling Win32 API using XNScript.Call
VBS Example:
Then we call MessageBox API using XNScript.call, and as you may already noticed we first pass it the win32 Dll name that contains this function then the Function Name followed by the function paramters.
Below is another example that shows the command line of the current process
Example: Calling Win32 API in another process using XNScript.CallInWindow
In all the previous examples we call win32 APIs from within XNeat process, but sometimes we need to call win32 API in another process here comes the need for XNScript.CallInWindow
VBS Example:
Example: XNScript.Loaddll as equivalent to XNScript.Call
VBS Example:
Then we call MessageBox API using the User32 object
This way makes the code more readable, and very handy if you are going to make many calls to the same dll
Example: XNScript.Loaddll as equivalent to XNScript.CallInWindow
Tutorial finished!
You may take a look at Creating Win32 Struct tutorial inorder to be able to call Win32 API that requires a pointer to struct.
It is recommended not to spik any example as they depend on each other.
Example: Calling Win32 API using XNScript.Call
VBS Example:
Dim XNScript
Set XNScript = WScript.CreateObject("XNeat.Core")
XNScript.call "user32.dll" , "MessageBox", 0 , "Calling MessageBox API using XNScript.call", "Example", 0
As you can see above first we get a handle to XNeat COM Object.Then we call MessageBox API using XNScript.call, and as you may already noticed we first pass it the win32 Dll name that contains this function then the Function Name followed by the function paramters.
Below is another example that shows the command line of the current process
Dim XNScript
Set XNScript = WScript.CreateObject("XNeat.Core")
Dim hWnd
hWnd = XNScript.Call ( "user32.dll", "GetForegroundWindow" )
Dim CmdPointer
CmdPointer = XNScript.Call( "kernel32.dll", "GetCommandLine" )
XNScript.Call "User32.dll", "MessageBox", 0, CmdPointer , "Example", 0
Example: Calling Win32 API in another process using XNScript.CallInWindow
In all the previous examples we call win32 APIs from within XNeat process, but sometimes we need to call win32 API in another process here comes the need for XNScript.CallInWindow
VBS Example:
Dim XNScript
Set XNScript = WScript.CreateObject("XNeat.Core")
Dim hWnd
hWnd = XNScript.Call ("user32.dll","GetForegroundWindow")
Dim CmdPointer
CmdPointer = XNScript.CallInWindow( hWnd, "kernel32.dll", "GetCommandLine" )
XNScript.CallInWindow hWnd, "user32.dll","MessageBox", 0, CmdPointer , "Example", 0
Example: XNScript.Loaddll as equivalent to XNScript.Call
VBS Example:
Dim XNScript
Set XNScript = WScript.CreateObject("XNeat.Core")
Dim User32
Set User32 = XNScript.LoadDll( "user32.dll" )
User32.MessageBox 0 , "Calling MessageBox API using XNScript.Loaddll", "Example", 0
As you can see we first load the dll where the API is located using XNScript.Loadddll and save the returned value in User32 object.
Then we call MessageBox API using the User32 object
This way makes the code more readable, and very handy if you are going to make many calls to the same dll
Example: XNScript.Loaddll as equivalent to XNScript.CallInWindow
Dim XNScript
Set XNScript = WScript.CreateObject("XNeat.Core")
Dim hWnd
hWnd = XNScript.Call ("User32.dll","GetForegroundWindow")
Dim User32InWnd
Set User32InWnd = XNScript.LoadDll( "user32.dll" , hWnd )
Dim Kernel32InWnd
Set Kernel32InWnd = XNScript.LoadDll( "kernel32.dll" , hWnd )
Dim CmdPointer
CmdPointer = Kernel32InWnd.GetCommandLine
User32InWnd.MessageBox 0, CmdPointer , "Example", 0
Tutorial finished!
You may take a look at Creating Win32 Struct tutorial inorder to be able to call Win32 API that requires a pointer to struct.