Skip to content
Get Free Trial

Windows Functions

Windows automation is supported since Sahi Pro Desktop Engine

Since
Desktop Engine 7.0.0

Modes Windows

_setSelectedExcelTab($element)

Arguments

NameTypeDescription
$elementstringExcel Sheet.

Returns

null

Select the specified sheet in Excel

_selectWindow("Book1 - Excel");
_setSelectedExcelTab("Sheet2"); // selects "Sheet2" tab in Book1 - Excel.
Since
Desktop Engine 7.0.0

Modes Windows

_setCell($element, $value)

Arguments

NameTypeDescription
$elementWindows elementcell whose value is to be set
$valuestringValue to be set

Returns

null

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

_setCell("A22","test");
Since
Desktop Engine 7.0.0

Modes Windows

_typeCell($element, $value)

Arguments

NameTypeDescription
$elementWindows elementcell element in which the text is to be typed
$valuestringValue to be set

Returns

null

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

_typeCell("A22","test");
Since
Desktop Engine 7.5.0

Modes Windows

_drag($dragElement)

Arguments

NameTypeDescription
$dragElementWindows elementelement to be dragged

Returns

null

Simulates a drag action

// Drag the item
_drag(_image("item.jpg"));
Since
Desktop Engine 7.5.0

Modes Windows

_drop($dropElement)

Arguments

NameTypeDescription
$dropElementWindowselement where the dragged element will be dropped

Returns

null

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"));
Since
Desktop Engine 8.0.0

Modes Windows

_attachExe($exeArgs, $arch)

Arguments

NameTypeDescription
$exeArgsstringpath of the application including command line arguments.
$archintegerarchitecture of the executable program. Can be either 32 or 64.

Returns

null

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);
Since
Desktop Engine 8.0.0

Modes Windows

_attach($x, $y, $arch)

Arguments

NameTypeDescription
$xintegerx-coordinate of the control
$yintegery-coordinate of the control
$archintegerarchitecture of the executable program. Can be either 32 or 64

Returns

null

Attaches the NX extension DLL for the specified coordinates and architecture of a control in a window.

_selectWindow("Application window name");
$pos = _position(_pane("Custom1"));
_attach($pos[0],$pos[1],32);
Since
Desktop Engine 8.0.0

Modes Windows

_capture($x, $y)

Arguments

NameTypeDescription
$xintegerx-coordinate of the control
$yintegery-coordinate of the control

Returns

null

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();
Since
Desktop Engine 8.0.0

Modes Windows

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

Arguments

NameTypeDescription
$windowNamestringname of the application window
$controlstringname of the control inside the window
$durationintegeroptionalduration for capturing UI render calls in milliseconds

Returns

null

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

_attachExe("app.exe",32);
_captureUI("windowName", "custom1");
_captureUI("windowName", "custom1", 5000);
Since
Desktop Engine 8.0.0

Modes Windows

_stopCapture()

Arguments

NameTypeDescription
None

Returns

null

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();
Since
Desktop Engine 8.0.0

Modes Windows

_nxTableCount()

Arguments

NameTypeDescription
None

Returns

integerNumber of tables rendered from NX

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();
Since
Desktop Engine 8.0.0

Modes Windows

_nxTable($table)

Arguments

NameTypeDescription
$tableintegerIndex of the table for getting the table data

Returns

objectTable data containing rows and cells

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}]] */
Since
Desktop Engine 8.0.0

Modes Windows

_nxCell($row, $column, $table)

Arguments

NameTypeDescription
$rowintegerIndex of the row
$columnintegerIndex of the column
$tableintegerIndex of the table

Returns

objectcell data

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}