jalsoedesign/cli-clipboard

启用剪贴板API,在多种平台上获取/设置和清除剪贴板

1.1.0 2019-07-18 16:46 UTC

This package is auto-updated.

Last update: 2024-09-19 04:04:36 UTC


README

启用剪贴板API,在多种平台上获取、设置和清除剪贴板(目前支持Windows和OSX)。

平台支持

不受支持的平台将使用MockClipboardApi API,该API将模拟剪贴板,但实际上不会对其本地状态之外的任何内容进行获取/设置/清除。

安装

composer require jalsoedesign/cli-clipboard

使用方法

获取当前剪贴板内容

// Instantiate the clipboard class
$clipboard = \jalsoedesign\CliClipboard\Clipboard::instance();

// Get the current contents of the clipboard
$contents = $clipboard->get();

// Print the content
echo $contents;

设置当前剪贴板内容

// Instantiate the clipboard class
$clipboard = \jalsoedesign\CliClipboard\Clipboard::instance();

// Set the current contents of the clipboard to "foobar"
$clipboard->set('foobar');

清除当前剪贴板内容

// Instantiate the clipboard class
$clipboard = \jalsoedesign\CliClipboard\Clipboard::instance();

// Clear the current clipboard contents
$clipboard->clear();