Windows Functions
Windows automation is supported since Sahi Pro Desktop Engine
_setSelectedExcelTab
Section titled “_setSelectedExcelTab”- Since
- Desktop Engine 7.0.0
Modes Windows
_setSelectedExcelTab($element)Arguments
| Name | Type | Description |
|---|---|---|
$element | string | Excel Sheet. |
Returns
null |
Select the specified sheet in Excel
_selectWindow("Book1 - Excel");_setSelectedExcelTab("Sheet2"); // selects "Sheet2" tab in Book1 - Excel._setCell
Section titled “_setCell”- Since
- Desktop Engine 7.0.0
Modes Windows
_setCell($element, $value)Arguments
| Name | Type | Description |
|---|---|---|
$element | Windows element | cell whose value is to be set |
$value | string | Value 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");_typeCell
Section titled “_typeCell”- Since
- Desktop Engine 7.0.0
Modes Windows
_typeCell($element, $value)Arguments
| Name | Type | Description |
|---|---|---|
$element | Windows element | cell element in which the text is to be typed |
$value | string | Value 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
| Name | Type | Description |
|---|---|---|
$dragElement | Windows element | element 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
| Name | Type | Description |
|---|---|---|
$dropElement | Windows | element 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"));NX Functions
Section titled “NX Functions”_attachExe
Section titled “_attachExe”- Since
- Desktop Engine 8.0.0
Modes Windows
_attachExe($exeArgs, $arch)Arguments
| Name | Type | Description |
|---|---|---|
$exeArgs | string | path of the application including command line arguments. |
$arch | integer | architecture 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);_attach
Section titled “_attach”- Since
- Desktop Engine 8.0.0
Modes Windows
_attach($x, $y, $arch)Arguments
| Name | Type | Description |
|---|---|---|
$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 |
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);_capture
Section titled “_capture”- Since
- Desktop Engine 8.0.0
Modes Windows
_capture($x, $y)Arguments
| Name | Type | Description |
|---|---|---|
$x | integer | x-coordinate of the control |
$y | integer | y-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();_captureUI
Section titled “_captureUI”- Since
- Desktop Engine 8.0.0
Modes Windows
_captureUI($windowName, $control[, $duration])Arguments
| Name | Type | Description |
|---|---|---|
$windowName | string | name of the application window |
$control | string | name of the control inside the window |
$duration | integeroptional | duration 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);_stopCapture
Section titled “_stopCapture”- Since
- Desktop Engine 8.0.0
Modes Windows
_stopCapture()Arguments
| Name | Type | Description |
|---|---|---|
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();_nxTableCount
Section titled “_nxTableCount”- Since
- Desktop Engine 8.0.0
Modes Windows
_nxTableCount()Arguments
| Name | Type | Description |
|---|---|---|
None |
Returns
integer | Number 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();_nxTable
Section titled “_nxTable”- Since
- Desktop Engine 8.0.0
Modes Windows
_nxTable($table)Arguments
| Name | Type | Description |
|---|---|---|
$table | integer | Index of the table for getting the table data |
Returns
object | Table 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}]] */_nxCell
Section titled “_nxCell”- Since
- Desktop Engine 8.0.0
Modes Windows
_nxCell($row, $column, $table)Arguments
| Name | Type | Description |
|---|---|---|
$row | integer | Index of the row |
$column | integer | Index of the column |
$table | integer | Index of the table |
Returns
object | cell 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}
