Windows APIs

Windows automation is supported since Sahi Pro Desktop Add-on

Set Selected Excel Tab

Select the specified sheet in Excel

Parameters
$elementstring Excel Sheet.
Return Value

Modes Supported :
Raw Script
_selectWindow("Book1 - Excel");
_setSelectedExcelTab("Sheet2");   // selects "Sheet2" tab in Book1 - Excel.

Sahi Pro Classic API :_setSelectedExcelTab


Set Cell

Value entered into the specified cell of the currently selected sheet Supports only cells within MS Excel framework

Parameters
$elementWindows element cell whose value is to be set
$valuestring Value to be set
Return Value

Modes Supported :
Raw Script
_setCell("A22","test");

Sahi Pro Classic API :_setCell


Type Cell

Value appended to the specific cell of the currently selected sheet Supports only cells within MS Excel framework

Parameters
$elementWindows element cell element in which the text is to be typed
$valuestring Value to be set
Return Value

Modes Supported :
Raw Script
_typeCell("A22","test");

Sahi Pro Classic API :_typeCell


Drag

Simulates a drag action

Parameters
$dragElementWindows element element to be dragged
Return Value

Modes Supported :
Raw Script
// Drag the item
_drag(_image("item.jpg"));

Sahi Pro Classic API :_drag


Drop

Simulates a drag and drop action

Parameters
$dropElementWindows 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

Attach Exe

Launches application with NX extension DLL for the specified architecture of a control in a window.

Parameters
$exeArgsstring path of the application including command line arguments.
$archinteger 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


Attach

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
$xinteger x-coordinate of the control
$yinteger y-coordinate of the control
$archinteger 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


Capture

Starts capturing native text API calls for the specified coordinates of a control in a window.

Parameters
$xinteger x-coordinate of the control
$yinteger 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


Capture UI

Starts capturing native text API calls for the specified coordinates of a control in a window.

Parameters
$windowNamestring name of the application window
$controlstring name of the control inside the window
$durationinteger optionalduration 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


Stop Capture

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


Nx Table Count

Gets the number of tables.

Parameters
None
Return Value
integerNumber 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


Nx Table

Gets the table data for a given table index.

Parameters
$tableinteger Index of the table for getting the table data
Return Value
objectTable 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


Nx Cell

Gets the cell data for given row, column and table index.

Parameters
$rowinteger Index of the row
$columninteger Index of the column
$tableinteger Index of the table
Return Value
objectcell 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