Windows APIs
Windows automation is supported since Sahi Pro Desktop Add-on
Select the specified sheet in Excel
Parameters
$element | string | Excel Sheet. |
Return Value
Modes Supported :
Raw Script
_selectWindow("Book1 - Excel");
_setSelectedExcelTab("Sheet2"); // selects "Sheet2" tab in Book1 - Excel.
Sahi Pro Classic API :_setSelectedExcelTab
Value entered into the specified cell of the currently selected sheet
Supports only cells within MS Excel framework
Parameters
$element | Windows element | cell whose value is to be set |
$value | string | Value to be set |
Return Value
Modes Supported :
Raw Script
_setCell("A22","test");
Sahi Pro Classic API :_setCell
Value appended to the specific cell of the currently selected sheet
Supports only cells within MS Excel framework
Parameters
$element | Windows element | cell element in which the text is to be typed |
$value | string | Value to be set |
Return Value
Modes Supported :
Raw Script
_typeCell("A22","test");
Sahi Pro Classic API :_typeCell
Simulates a drag action
Parameters
$dragElement | Windows element | element to be dragged |
Return Value
Modes Supported :
Raw Script
// Drag the item
_drag(_image("item.jpg"));
Sahi Pro Classic API :_drag
Simulates a drag and drop action
Parameters
$dropElement | Windows | element where the dragged element will be dropped |
Return Value
Modes Supported :
Raw Script
// Drop it at images folder
_drop(_listItem("images"));
Sahi Pro Classic API :_drop
NX APIs
Launches application with NX extension DLL for the specified architecture of a control in a window.
Parameters
$exeArgs | string | path of the application including command line arguments. |
$arch | integer | architecture of the executable program. Can be either 32 or 64. |
Return Value
Modes Supported :
Raw Script
_attachExe("app.exe",32);
_attachExe("app.exe -someOption=1",32);
Sahi Pro Classic API :_attachExe
Attaches the NX extension DLL for the specified coordinates and architecture of a control in a window.
info
Note: To make the Attach API work it is required to start the SahiWinNX.exe or SahiWinNX64.exe under SAHI_INSTALLATION/windows/bin directory.
info
Note: Use this API only if you don't have access to the application's executable file or the application doesn't have an executable format.
Parameters
$x | integer | x-coordinate of the control |
$y | integer | y-coordinate of the control |
$arch | integer | architecture of the executable program. Can be either 32 or 64 |
Return Value
Modes Supported :
Raw Script
_selectWindow("Application window name");
$pos = _position(_pane("Custom1"));
_attach($pos[0],$pos[1],32);
Sahi Pro Classic API :_attach
Starts capturing native text API calls for the specified coordinates of a control in a window.
Parameters
$x | integer | x-coordinate of the control |
$y | integer | y-coordinate of the control |
Return Value
Modes Supported :
Raw Script
_attachExe("app.exe",32);
_selectWindow("windowName");
$pos = _position(_pane("Custom1"));
_capture($pos[0],$pos[1]);
_wait(2000); // specify wait for the NX extension to capture adequate UI render calls
_stopCapture();
Sahi Pro Classic API :_capture
Starts capturing native text API calls for the specified coordinates of a control in a window.
Parameters
$windowName | string | name of the application window |
$control | string | name of the control inside the window |
$duration | integer optional | duration for capturing UI render calls in milliseconds |
Return Value
Modes Supported :
Raw Script
_attachExe("app.exe",32);
_captureUI("windowName", "custom1");
_captureUI("windowName", "custom1", 5000);
Sahi Pro Classic API :_captureUI
Stops capturing UI render calls. Contructs the NX psuedo-element tables after this call.
Parameters
None |
Return Value
Modes Supported :
Raw Script
_selectWindow("windowName");
var $pos = _position(_pane("Custom1"));
_attach($pos[0],$pos[1],32);
_capture($pos[0],$pos[1]);
_wait(2000); // specify wait for the NX extension to capture adequate UI render calls
_stopCapture();
Sahi Pro Classic API :_stopCapture
Gets the number of tables.
Parameters
None |
Return Value
integer | Number of tables rendered from NX |
Modes Supported :
Raw Script
//example using _capture API
_selectWindow("windowName");
var $pos = _position(_pane("Custom1"));
_attach($pos[0],$pos[1],32);
_capture($pos[0],$pos[1]);
_wait(2000); // specify wait for the NX extension to capture adequate UI render calls
_stopCapture();
var $noOfTables = _nxTableCount();
Sahi Pro Classic API :_nxTableCount
Gets the table data for a given table index.
Parameters
$table | integer | Index of the table for getting the table data |
Return Value
object | Table data containing rows and cells |
Modes Supported :
Raw Script
_selectWindow("windowName");
var $pos = _position(_pane("Custom1"));
_attach($pos[0],$pos[1],32);
_capture($pos[0],$pos[1]);
_stopCapture();
var $table = _nxTable(0);
/* returns [[{"text":"&File","x":687,"y":387,"tab":0,"row":0,"col":0}
,{"text":"&Edit","x":719,"y":387,"tab":0,"row":0,"col":1}
,{"text":"&Options","x":753,"y":387,"tab":0,"row":0,"col":2}
,{"text":"&Help","x":809,"y":387,"tab":0,"row":0,"col":3}]] */
Sahi Pro Classic API :_nxTable
Gets the cell data for given row, column and table index.
Parameters
$row | integer | Index of the row |
$column | integer | Index of the column |
$table | integer | Index of the table |
Return Value
object | cell data |
Modes Supported :
Raw Script
_selectWindow("MFC Grid Control Demo");
var $pos = _position(_pane("Custom1"));
_attach($pos[0],$pos[1],32);
_caputureUI("windowName", "control");
var $cell = _nxCell(0,0,0); // returns {"text":"&File","x":687,"y":387,"tab":0,"row":0,"col":0}
Sahi Pro Classic API :_nxCell