clipboard_get_dataΒΆ

clipboard_get_data returns the clipboard data as a string. The sting can contain 0-characters.

data = clipboard_get_data(iFormat)
data = clipboard_get_data(ssName)

Return Value

data contains the clipboard data as a Unscript string. Two bytes from the clipboard are written into one Uniscript character.

Parameters

iFormat

iFormat is the format index.

ssName

ssName is the format name.

Example

// The explorer writes the format CF_HDROP if files are copied into the
// clipboard.
// The format contains a header followed by the file names which are
// separated by 0 characters. The end of the format contains two 0-characters.
def test_hdrop()
{
    s = clipboard_get_data("CF_HDROP");
    nBytes = mem_len(s);
    if (nBytes == 0) {
        error("CF_HDROP not available");
    }
    // The first interger is offset to the next file name.
    offset = mem_get(s, 1, "uint32", 1);
    v = mem_get(s, offset+1, "wchar_t", (nBytes-offset)/2);
    idx = find(v == 0);
    start = 1;
    nNames = len(idx)-1;
    sv = strempty(nNames, 1);
    for (i in 1:len(idx)-1) {
        sv[i] = strchar(v[start:idx[i]-1])
        start = idx[i] + 1;
    }
    return sv;
}

History

Version Description
5.9 New

id-1931826