Sahi Documentation

Windows APIs

Windows automation is supported since Sahi Pro Desktop Add-on

_setSelectedExcelTab

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANA7.0.0NANANA

Available for modes: Windows

_setSelectedExcelTab($element)

Arguments
$elementstring Excel Sheet.

Returns
null

Details

Select the specified sheet in Excel
_selectWindow("Book1 - Excel");
_setSelectedExcelTab("Sheet2");   // selects "Sheet2" tab in Book1 - Excel.


_setCell

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANA7.0.0NANANA

Available for modes: Windows

_setCell($element, $value)

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

Returns
null

Details

Value entered into the specified cell of the currently selected sheet Supports only cells within MS Excel framework
_setCell("A22","test");


_typeCell

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANA7.0.0NANANA

Available for modes: Windows

_typeCell($element, $value)

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

Returns
null

Details

Value appended to the specific cell of the currently selected sheet Supports only cells within MS Excel framework
_typeCell("A22","test");


_drag

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANA7.5.0NANANA

Available for modes: Windows

_drag($dragElement)

Arguments
$dragElementWindows element element to be dragged

Returns
null

Details

Simulates a drag action
// Drag the item
_drag(_image("item.jpg"));


_drop

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANA7.5.0NANANA

Available for modes: Windows

_drop($dropElement)

Arguments
$dropElementWindows element where the dragged element will be dropped

Returns
null

Details

Simulates a drag and drop action
// Drop it at images folder
_drop(_listItem("images"));


// drag and drop action on same window
_selectWindow("Source Window");
_drag(_image("item.jpg"));
_drop(_listItem("images"));

// drag and drop action on different window
_selectWindow("Source Window");
_drag(_image("item.jpg"));
_selectWindow("Destination Window");
_drop(_listItem("images"));


NX APIs

_attachExe

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANA8.0.0NANANA

Available for modes: Windows

_attachExe($exeArgs, $arch)

Arguments
$exeArgsstring path of the application including command line arguments.
$archinteger architecture of the executable program. Can be either 32 or 64.

Returns
null

Details

Launches application with NX extension DLL for the specified architecture of a control in a window.
_attachExe("app.exe",32);
_attachExe("app.exe -someOption=1",32);


_attach

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANA8.0.0NANANA

Available for modes: Windows

_attach($x, $y, $arch)

Arguments
$xinteger x-coordinate of the control
$yinteger y-coordinate of the control
$archinteger architecture of the executable program. Can be either 32 or 64

Returns
null

Details

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.
_selectWindow("Application window name");
$pos = _position(_pane("Custom1"));
_attach($pos[0],$pos[1],32);


_capture

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANA8.0.0NANANA

Available for modes: Windows

_capture($x, $y)

Arguments
$xinteger x-coordinate of the control
$yinteger y-coordinate of the control

Returns
null

Details

Starts capturing native text API calls for the specified coordinates of a control in a window.
_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();
warning Note: You must call the _stopCapture API to stop the capture process after _capture API call.


_captureUI

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANA8.0.0NANANA

Available for modes: Windows

_captureUI($windowName, $control[, $duration])

Arguments
$windowNamestring name of the application window
$controlstring name of the control inside the window
$durationinteger optionalduration for capturing UI render calls in milliseconds

Returns
null

Details

Starts capturing native text API calls for the specified coordinates of a control in a window.
_attachExe("app.exe",32);
_captureUI("windowName", "custom1");
_captureUI("windowName", "custom1", 5000);
info Note: The _stopCapture() API is not necessary after the _captureUI API.


_stopCapture

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANA8.0.0NANANA

Available for modes: Windows

_stopCapture()

Arguments
None

Returns
null

Details

Stops capturing UI render calls. Contructs the NX psuedo-element tables after this call.
_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();


_nxTableCount

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANA8.0.0NANANA

Available for modes: Windows

_nxTableCount()

Arguments
None

Returns
integerNumber of tables rendered from NX

Details

Gets the number of tables.
//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();
//example using _captureUI
_selectWindow("windowName");
var $pos = _position(_pane("Custom1"));
_attach($pos[0],$pos[1],32);
_captureUI("windowName", "custom1");
var $noOfTables = _nxTableCount();


_nxTable

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANA8.0.0NANANA

Available for modes: Windows

_nxTable($table)

Arguments
$tableinteger Index of the table for getting the table data

Returns
objectTable data containing rows and cells

Details

Gets the table data for a given table index.
_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}]] */


_nxCell

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANA8.0.0NANANA

Available for modes: Windows

_nxCell($row, $column, $table)

Arguments
$rowinteger Index of the row
$columninteger Index of the column
$tableinteger Index of the table

Returns
objectcell data

Details

Gets the cell data for given row, column and table index.
_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}