Show / Hide Table of Contents

Class clipboardData

Sets or gets clipboard data in multiple formats.

public class clipboardData
Remarks

The AddX functions add data to the variable (not to the clipboard). Then clipboardData.SetClipboard copies the added data to the clipboard. Also you can use the variable with clipboard.pasteData. The static GetX functions get data directly from the clipboard.

Examples

Get bitmap image from clipboard.

var image = clipboardData.getImage();
if(image == null) print.it("no image in clipboard"); else print.it(image.Size);

Set clipboard data in two formats: text and image.

new clipboardData().AddText("text").AddImage(Image.FromFile(@"C:\file.png")).SetClipboard();

Paste data of two formats: HTML and text.

clipboard.pasteData(new clipboardData().AddHtml("<b>text</b>").AddText("text"));

Copy data in two formats: HTML and text.

string html = null, text = null;
clipboard.copyData(() => { html = clipboardData.getHtml(); text = clipboardData.getText(); });
print.it(html); print.it(text);

Namespace: Au
Assembly: Au.dll
Inheritance
object
clipboardData

Methods

Name Description
AddBinary(byte[], int)

Adds data of any format as byte[].

AddFiles(params string[])

Adds list of files to copy/paste. Uses clipboard format ClipFormats.Files (CF_HDROP).

AddHtml(string)

Adds HTML text. Uses clipboard format ClipFormats.Html ("HTML Format").

AddImage(Image, bool?)

Adds image. Uses clipboard format ClipFormats.Png and/or ClipFormats.Image (CF_BITMAP).

AddText(string, int)

Adds text.

SetClipboard()

Copies the added data of all formats to the clipboard.

SetOpenClipboard(bool, int)

Copies the added data of all formats to the clipboard which is open/owned by this thread.

contains(int)

Returns true if the clipboard contains data of the specified format.

contains(params int[])

Returns the first of the specified formats that is in the clipboard. Returns 0 if the clipboard is empty. Returns -1 if the clipboard contains data but not in any of the specified formats.

getBinary(int)

Gets clipboard data of any format as byte[].

getBinary<T>(int, Func<nint, int, T>)

Gets clipboard data of any format without copying to array. Uses a callback function.

getFiles()

Gets file paths from the clipboard. Uses clipboard format ClipFormats.Files (CF_HDROP).

getHtml()

Gets HTML text from the clipboard. Uses clipboard format ClipFormats.Html ("HTML Format").

getHtml(out int, out int, out string)

Gets HTML text from the clipboard. Uses clipboard format ClipFormats.Html ("HTML Format").

getImage(bool?)

Gets image from the clipboard. Uses clipboard format ClipFormats.Png or ClipFormats.Image (CF_BITMAP).

getText(int)

Gets text from the clipboard.