# Function Reference

# _ClipBoard_SetData

Places data on the clipboard in a specified clipboard format

#include <Clipboard.au3>
_ClipBoard_SetData ( $vData [, $iFormat = $CF_TEXT] )

## Parameters

$vData | Data in Binary or String format, or optionally NULL (0) (owner must render, see below). IMPORTANT: If a String is passed, and it is not of type $CF_TEXT, $CF_OEMTEXT, or $CF_UNICODETEXT, it will be treated as an ANSI string. To force Unicode strings for other types, you must pass the data in Binary format. Also, do NOT pass $CF_UNICODETEXT in Binary format (causes garbled data). When $vData is NULL, it indicates that the window provides data in the specified clipboard format upon request. If a window delays rendering, it must process the $WM_RENDERFORMAT and $WM_RENDERALLFORMATS messages. If this function succeeds, the system owns the object identified by the $hMemory parameter. The application may not write to or free the data once ownership has been transferred to the system, but it can lock and read from the data until the _ClipBoard_Close() function is called. The memory must be unlocked before the clipboard is closed. If the $hMemory parameter identifies a memory object, the object must have been allocated using the function with the $GMEM_MOVEABLE flag.
$iFormat | [optional] Specifies a clipboard format: $CF_TEXT - Text format (default) $CF_BITMAP - Handle to a bitmap (HBITMAP) $CF_METAFILEPICT - Handle to a metafile picture (METAFILEPICT) $CF_SYLK - Microsoft Symbolic Link (SYLK) format $CF_DIF - Software Arts' Data Interchange Format $CF_TIFF - Tagged image file format $CF_OEMTEXT - Text format containing characters in the OEM character set $CF_DIB - BITMAPINFO structure followed by the bitmap bits $CF_PALETTE - Handle to a color palette $CF_PENDATA - Data for the pen extensions to Pen Computing $CF_RIFF - Represents audio data in RIFF format $CF_WAVE - Represents audio data in WAVE format $CF_UNICODETEXT - Unicode text format $CF_ENHMETAFILE - Handle to an enhanced metafile (HENHMETAFILE) $CF_HDROP - Handle to type HDROP that identifies a list of files $CF_LOCALE - Handle to the locale identifier associated with text in the clipboard $CF_DIBV5 - BITMAPV5HEADER structure followed by bitmap color and the bitmap bits $CF_OWNERDISPLAY - Owner display format $CF_DSPTEXT - Text display format associated with a private format $CF_DSPBITMAP - Bitmap display format associated with a private format $CF_DSPMETAFILEPICT - Metafile picture display format associated with a private format $CF_DSPENHMETAFILE - Enhanced metafile display format associated with a private format

## Return Value

Success: | The handle to the data
Failure: | 0

## Remarks

This function performs all of the steps neccesary to put data on the clipboard. It will allocate the global memory object, open the clipboard, place the data on the clipboard and close the clipboard. If you need more control over putting data on the clipboard, you may want to use the _ClipBoard_SetDataEx() function.

## Related

_ClipBoard_Empty, _ClipBoard_GetData, _ClipBoard_GetDataEx, _ClipBoard_SetDataEx

## Example

    #include "Extras\HelpFileInternals.au3"

    #include <Clipboard.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsStylesConstants.au3>

    Example()

    Func Example()
        Local $idBtn_SetData, $idBtn_GetData

        ; Create GUI
        GUICreate("Clipboard", 600, 450)
        _MemoCreate(2, 2, 596, 396, $WS_VSCROLL)
        $idBtn_SetData = GUICtrlCreateButton("Set ClipBoard Data", 150, 410, 120, 30)
        $idBtn_GetData = GUICtrlCreateButton("Get ClipBoard Data", 300, 410, 120, 30)
        GUISetState(@SW_SHOW)

        ; Loop until the user exits.
        While 1
            Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                    ExitLoop
                Case $idBtn_SetData
                    _ClipBoard_SetData("ClipBoard Library")
                Case $idBtn_GetData
                    _MemoWrite(_ClipBoard_GetData())
            EndSwitch
        WEnd
    EndFunc   ;==>Example