我的剪貼簿管理工具主力是Ditto,Ditto輕量簡便,但並無自訂功能,最近重新安裝了CopyQ,並嘗試做了一些設定與自訂命令,讓剪貼簿操作能依需求處理,從而增進執行效率。本文介紹幾個我的自訂功能,希望能帶給各位一些剪貼簿應用上的啟發。
CopyQ是使用QT撰寫的軟體,因此能在Windows、macOS與Linux上執行,並開源於GitHub。
CopyQ的複製內容會逐次存入稱為「History」的區域,按一次Ctrl+C就會存入History的Clipboard分頁,點擊History區的任一項目,項目內容會存入系統剪貼簿,並複製到作用中的應用程式內。
我的第一類增強是備份特定內容到添加的分頁。
這個需求是方便找到需要的資料。雖然在預設的Clipboard分頁可以按Ctrl+F搜尋找到需要的資料,但若能自動分類就能更迅速的尋獲要再次使用的內容。
http://
或https://
),自動複製到 URL 分頁字母:\
自動複製到 Folders 分頁第二類增強是直接取用第 n 個複製項目內容:
開啟CopyQ主視窗後,按F6或點擊功能表【File】→【Commands...】即能維護自訂命令。
[!tip] 心得
Automatic與Gobal shortcut通常不會同時勾選
點選功能表【Tabs】→【New Tab】以添加新的分頁,如 Images、URL與Folders分頁。
[!tip] 除錯
可使用popup(標題, 內容)
除錯,內容會以通知形式顯示在右下角
另一個使用腳本的方法:
copyq:
var currentFormats = dataFormats();
// 判斷陣列中是否包含圖片格式
if (currentFormats.indexOf("image/png") !== -1 ||
currentFormats.indexOf("image/jpeg") !== -1 ||
currentFormats.indexOf("image/gif") !== -1) {
//popup("複製內容", "剪貼簿包含圖片。");
//tab('Images');
setData(mimeOutputTab, "Images")
}
copyq:
// 讀取剪貼簿的純文字內容
var text = str(clipboard());
//popup('popup', text);
// 檢查文字是否以 http: 或 https: 開頭
var _iIndex = -1;
var _iIndex1 = text.indexOf('http://';);
var _iIndex2 = text.indexOf('https://';);
if (_iIndex1 >= 0) {
text = text.substring(_iIndex1);
_iIndex = text.indexOf(')', _iIndex1+1);
if (_iIndex > 0) {
text = text.substring(0, _iIndex);
}
_iIndex = _iIndex1;
}
if (_iIndex2 >= 0) {
text = text.substring(_iIndex2);
_iIndex = text.indexOf(')', _iIndex1+1);
if (_iIndex > 0) {
text = text.substring(0, _iIndex);
}
_iIndex = _iIndex2;
}
if (_iIndex >= 0) {
tab('URL');
add(text);
}
### 3.3. 備份資料夾
- 勾選【Automatic】
```js
copyq:
// 讀取剪貼簿的純文字內容
var text = str(clipboard());
var drive = text.toUpperCase()
drive = drive.substr(0,2);
colon = text.substr(1,2);
//popup('popup', text+"/ " + drive + '/' + colon);
if (colon == ':' && drive >= 'C:' && drive <= 'Z:') {
//popup('popup', text);
tab('Folders');
add(text);
}
copyq:
// 複製第一項項目
select(0);
paste();
copyq:
// 複製第2項項目
select(1);
paste();
copyq:
// 在主視窗點擊要複製的項目
var _iItem = currentItem();
popup("msg", str(_iItem));
select(_iItem);
paste();
next();
✅ 解說文章(繁體中文): https://jdev.tw/blog/8881/
✅ Explanation article(English)
✅ 解説記事(日本語)
✅ Ditto Clipboard Manager
✅ GitHub CopyQ: Clipboard manager with advanced features
✅ CopyQ documentation
##