How To Invoke External DLL’s | VBScript

Testmate provides the capability to invoke procedures in external DLL’s.

The below code demonstrates the usage of  LoadAndRun method to invoke SetForegroundWindow method from user32.dl:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'Declare The DLL to be used
 sDLL = "user32.dll"
 
'Declare the returrn type - Which is boolean
 sRet = "bool"
 
'Declare the method string
 sDec = "static extern bool SetForegroundWindow(IntPtr hWnd)"
 
'Fetch the handle of the application
 hwndCalculator = Native.GetHandleByCaption("Calculator")
 
'Declare the Method string
 sFunc = "SetForegroundWindow((IntPtr)" & hwndCalculator &" )"
 
'Run the method from the DLL
 Call dll.LoadAndRun(sDLL,sRet,sDec,sFunc)
 
All the available DLL's and methods can be found <a href="https://pinvoke.net/default.aspx/user32.SetForegroundWindow" target="_blank" rel="noopener">here</a>.

Add a Comment

Your email address will not be published. Required fields are marked *