XNeat Scripting Documentation

XNeat has a lot of events that could be handled using XNScript.AddEventListener API

Below is list of the events that are fired by XNeat:
1- ScriptsUnload: fired before the scripts are being unloaded, clean stuff here.
Parameters: takes no parameters.
2- ScriptsLoaded: called after all the scripts are being loaded
Parameters: takes no parameters.
3- WindowCreated: called whenever a top-level, unowned window created.
Parameters: WindowsHandle , WindowProcessName

Example:
XNScript.AddEventListener "windowcreated", GetRef("OnWindowCreated")

Dim User32
Set User32 = XNScript.loaddll("user32.dll")

Function OnWindowCreated( hWnd, szProcessName )
	If szProcessName = "calc.exe" Then
		MakeOnTop hWnd , True
	End If
End Function

Function MakeOnTop( hWnd , isOnTop )
	Const HWND_TOPMOST = -1
	Const SWP_NOMOVE = &H0002 
	Const SWP_NOSIZE = 1
	Const SWP_FRAMECHANGED = &H20
	Const HWND_NOTOPMOST = -2
	if CBool(isOnTop) = True Then
		User32.SetWindowPos CLng(hWnd), HWND_TOPMOST, 0, 0, 0, 0,SWP_NOMOVE or SWP_NOSIZE or SWP_FRAMECHANGED
	else
		User32.SetWindowPos CLng(hWnd), HWND_NOTOPMOST, 0, 0, 0, 0,SWP_NOMOVE or SWP_NOSIZE or SWP_FRAMECHANGED
	end if
End Function
The above script will make any calc.exe window stays always on top.
It first registers WindowCreated event, then it checks if the created window is calc.exe if so it makes it on top using SetWindowPos win32 API.
To test this script you have to install it first, if you don't know how to install XNeat scripts please check Getting Started tutorial.
After installing it runs calc.exe ( start -> run -> calc.exe )