Windows APIs
Windows automation is supported since Sahi Pro Desktop Engine
Set Selected Excel Tab
Section titled “Set Selected Excel Tab”Modes Windows
Select the specified sheet in Excel
Parameters
| Name | Type | Description |
|---|---|---|
$element | string | Excel Sheet. |
Raw script
_selectWindow("Book1 - Excel");_setSelectedExcelTab("Sheet2"); // selects "Sheet2" tab in Book1 - Excel.Sahi Pro Classic API _setSelectedExcelTab
Set Cell
Section titled “Set Cell”Modes Windows
Value entered into the specified cell of the currently selected sheet Supports only cells within MS Excel framework
Parameters
| Name | Type | Description |
|---|---|---|
$element | Windows element | cell whose value is to be set |
$value | string | Value to be set |
Raw script
_setCell("A22","test");Sahi Pro Classic API _setCell
Type Cell
Section titled “Type Cell”Modes Windows
Value appended to the specific cell of the currently selected sheet Supports only cells within MS Excel framework
Parameters
| Name | Type | Description |
|---|---|---|
$element | Windows element | cell element in which the text is to be typed |
$value | string | Value to be set |
Raw script
_typeCell("A22","test");Sahi Pro Classic API _typeCell
Modes Windows
Simulates a drag action
Parameters
| Name | Type | Description |
|---|---|---|
$dragElement | Windows element | element to be dragged |
Raw script
// Drag the item_drag(_image("item.jpg"));Sahi Pro Classic API _drag
Modes Windows
Simulates a drag and drop action
Parameters
| Name | Type | Description |
|---|---|---|
$dropElement | Windows | element where the dragged element will be dropped |
Raw script
// Drop it at images folder_drop(_listItem("images"));Sahi Pro Classic API _drop
NX APIs
Section titled “NX APIs”Attach Exe
Section titled “Attach Exe”Modes Windows
Launches application with NX extension DLL for the specified architecture of a control in a window.
Parameters
| 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. |
Raw script
_attachExe("app.exe",32);_attachExe("app.exe -someOption=1",32);Sahi Pro Classic API _attachExe
Attach
Section titled “Attach”Modes Windows
Attaches the NX extension DLL for the specified coordinates and architecture of a control in a window.
Parameters
| 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 |
Raw script
_selectWindow("Application window name");$pos = _position(_pane("Custom1"));_attach($pos[0],$pos[1],32);Sahi Pro Classic API _attach
Capture
Section titled “Capture”Modes Windows
Starts capturing native text API calls for the specified coordinates of a control in a window.
Parameters
| Name | Type | Description |
|---|---|---|
$x | integer | x-coordinate of the control |
$y | integer | y-coordinate of the control |
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
Section titled “Capture UI”Modes Windows
Starts capturing native text API calls for the specified control in a window.
Parameters
| 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 |
Raw script
_attachExe("app.exe",32);_captureUI("windowName", "custom1");_captureUI("windowName", "custom1", 5000);Sahi Pro Classic API _captureUI
Stop Capture
Section titled “Stop Capture”Modes Windows
Stops capturing UI render calls. Contructs the NX psuedo-element tables after this call.
Parameters
| Name | Type | Description |
|---|---|---|
None |
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
Section titled “Nx Table Count”Modes Windows
Gets the number of tables.
Parameters
| Name | Type | Description |
|---|---|---|
None |
Returns
integer | Number of tables rendered from NX |
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
Section titled “Nx Table”Modes Windows
Gets the table data for a given table index.
Parameters
| Name | Type | Description |
|---|---|---|
$table | integer | Index of the table for getting the table data |
Returns
object | Table data containing rows and cells |
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
Section titled “Nx Cell”Modes Windows
Gets the cell data for given row, column and table index.
Parameters
| 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 |
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

