# MX\_CLIPBOARD

> [HTML Version](mx_clipboard.htm)

_Reviewed and revised April 2024_

**xcall MIAMEX, MX\_CLIPBOARD, opcode, text \{,status \{,srow, scol, erow, ecol\}\}**

MX\_CLIPBOARD (MIAMEX 105) allows you to retrieve or set the text contents of the clipboard.

This function has both a [subroutine and a print tab implementation](subroutine-print-pairs.md).

**Parameters**

_opcode_  ([Num](num.md))  \[in\]

| **Value** | **Description** |
|------|------|
| 0 (MXOP\_GET) | Retrieve clipboard text contents |
| 1 (MXOP\_SET) | Set clipboard text either from screen coordinates (if non-zero) or from _text_ parameter |
| 2 | Same as 0 but applies to ATE client |
| 3 | Same as 1 but applies to ATE client |
| 5 | Mark area specified by coordinates |




Note that in non-ATE A-Shell/Unix environments, _opcode_ 0 (MXOP\_GET) and 1 (MXOP\_sET) will simulate clipboard operations by reading/writing to a file MEM0:<job>.CLP\[1,1\] if the file exists. If it does not exist, status will be set to -1, the same as if the Windows clipboard could not be opened.

_text_  ([String](string.md))  \[in/out\]

will receive the clipboard text contents for _opcode_ 0 and 2. For _opcode _1 and 3, if you want to specify a string containing the text to copy to the clipboard, then put it in the text parameter and do not specify the _srow_, _scol_, _erow_, and _ecol_ parameters (or set them to 0). Otherwise, if you want to copy a rectangular area of the current screen to the clipboard, then specify the coordinates in the last four parameters, in which case _text_ will be ignored. The maximum effective size for _text_ is about 3K.

_status_  ([Signed Int](integer-signed.md))  \[out\]  

| **Value** | **Description** |
|------|------|
| 0 | Success |
| \-1 | Unable to open clipboard; locked? |
| \-2 | Clipboard can be opened but not read, or there is no text available in the clipboard |
| \-3 | Unable to lock memory |
| \-4 | Invalid coordinates |
| \-99 | Failure communicating with ATE client |






_srow,scol,erow,ecol_  ([Num](num.md))  \[in\]

Optional coordinates used with opcodes 1, 3 to specify the screen area to be copied to the clipboard. (Set them all to 0 in order to load the clipboard from the text parameter instead of the screen.) For opcode 5, they specify the screen area to be marked. Ignored for all other opcodes.

**Comments**

Other than the non-GUI A-Shell/Unix case just mentioned, you can safely used _opcodes_ 2 and 3 in place of 0 and 1 (i.e. add +2) without regard to whether the configuration involves ATE or some other Windows architecture (standalone, peer-to-peer, Terminal Server, etc.).

In the Windows environment, MX\_CLIPBOARD internally uses the AG\_CLIPBOARD implementation.

The keyboard command CTRL+SHIFT+ALT+S can also be used to copy the current screen text contents to the clipboard.

**See Also**

•	[AG\_CLIPBOARD](ag_clipboard.md)