通過觀察ditto的表發現, 可以新增觸發器進行統計貼上次數的功能,不需要用原始碼
Ditto 是一款強大的 Windows 剪貼簿增強工具,它支援64位元作業系統,而且完全免費,綠色開源,支援中文,而且還有免安裝的綠色版本。
開啟 Ditto 後,不會有任何程式介面出現,它只是默默地在系統右下角彈出了一個藍色的托盤圖示,這時候你複製任何內容到剪貼簿都會被 Ditto 一一記錄。如果你什麼時候想找到它,就可以按 Ctrl+`,當中的每條內容都可以供你選擇性的重新複製。
Types
MainDeletes
Main
Data
CopyBuffers
/*
Navicat Premium Data Transfer
Source Server : ditto
Source Server Type : SQLite
Source Server Version : 3035005 (3.35.5)
Source Schema : main
Target Server Type : SQLite
Target Server Version : 3035005 (3.35.5)
File Encoding : 65001
Date: 17/04/2023 10:44:23
*/
PRAGMA foreign_keys = false;
-- ----------------------------
-- Table structure for Main
-- ----------------------------
DROP TABLE IF EXISTS "Main";
CREATE TABLE "Main" (
"lID" INTEGER PRIMARY KEY AUTOINCREMENT,
"lDate" INTEGER,
"mText" TEXT,
"lShortCut" INTEGER,
"lDontAutoDelete" INTEGER,
"CRC" INTEGER,
"bIsGroup" INTEGER,
"lParentID" INTEGER,
"QuickPasteText" TEXT,
"clipOrder" REAL,
"clipGroupOrder" REAL,
"globalShortCut" INTEGER,
"lastPasteDate" INTEGER,
"stickyClipOrder" REAL,
"stickyClipGroupOrder" REAL,
"MoveToGroupShortCut" INTEGER,
"GlobalMoveToGroupShortCut" INTEGER
);
-- ----------------------------
-- Auto increment value for Main
-- ----------------------------
UPDATE "sqlite_sequence" SET seq = 50355 WHERE name = 'Main';
-- ----------------------------
-- Indexes structure for table Main
-- ----------------------------
CREATE INDEX "Main_CRC"
ON "Main" (
"CRC" ASC
);
CREATE INDEX "Main_ClipGroupOrder"
ON "Main" (
"clipGroupOrder" DESC
);
CREATE INDEX "Main_ClipOrder"
ON "Main" (
"clipOrder" DESC
);
CREATE UNIQUE INDEX "Main_ID"
ON "Main" (
"lID" ASC
);
CREATE INDEX "Main_InGroup2"
ON "Main" (
"lParentId" ASC,
"stickyClipGroupOrder" DESC,
"bIsGroup" ASC,
"clipGroupOrder" DESC
);
CREATE INDEX "Main_IsGroup"
ON "Main" (
"bIsGroup" DESC
);
CREATE INDEX "Main_MoveToGroup"
ON "Main" (
"MoveToGroupShortCut" DESC,
"GlobalMoveToGroupShortCut" DESC
);
CREATE INDEX "Main_ParentId"
ON "Main" (
"lParentID" DESC
);
CREATE INDEX "Main_ShortCut2"
ON "Main" (
"lShortCut" DESC,
"globalShortCut" DESC
);
CREATE INDEX "Main_TopLevel"
ON "Main" (
"stickyClipOrder" DESC,
"bIsGroup" ASC,
"clipOrder" DESC
);
CREATE INDEX "Main_TopLevelParentID"
ON "Main" (
"lParentId" ASC,
"stickyClipOrder" DESC,
"bIsGroup" ASC,
"clipOrder" DESC
);
-- ----------------------------
-- Triggers structure for table Main
-- ----------------------------
CREATE TRIGGER "delete_data_trigger"
BEFORE DELETE
ON "Main"
FOR EACH ROW
BEGIN
INSERT INTO MainDeletes VALUES(old.lID, datetime('now'));
END;
PRAGMA foreign_keys = true;
通過表結構發現裡面是有一個觸發器進行記錄刪除時間的
同理可以增加一個觸發器,記錄更新時間,就可以記錄下貼上的使用id和時間
-- 新增 ditto 觸發器
DROP TRIGGER "main"."update_date_trigger"
CREATE TRIGGER "main"."update_date_trigger"
BEFORE UPDATE
ON "Main"
BEGIN
-- 這裡是因為貼上一次,會進行兩次update, 所以這裡刪除掉已經記錄的時間,避免生成兩個一樣的記錄
DELETE FROM MainPaste WHERE lastPasteDate=old.lastPasteDate;
-- 記錄一次貼上記錄
INSERT INTO MainPaste VALUES(old.lID, old.lastPasteDate);
END
COMMIT;
測試結論,通過貼上四次 「好的」, 可以查詢出複製了四次
-- 統計貼上次數
select t1.*, t2.mText from
( select clipID, count(clipID) cnt from MainPaste group by clipID order by count(clipID) desc) t1,
Main t2
where t1.clipID = t2.lID;