feat: 添加clipboard-event不同平台源代码

This commit is contained in:
ZiuChen
2022-09-20 00:00:11 +08:00
parent 19f6d1867d
commit 130d729af8
3 changed files with 106 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
//
// main.swift
// clipboard-event
//
// Created by Joonhee Lee on 2021/01/30.
//
import Foundation
import Cocoa
let pasteboard: NSPasteboard = NSPasteboard.general
var count: Int = pasteboard.changeCount
var saved: String = pasteboard.string(forType: .string) ?? "null"
repeat{
usleep(500000)
if(count < pasteboard.changeCount && saved != pasteboard.string(forType: .string)){
usleep(100000)
count = pasteboard.changeCount
saved = pasteboard.string(forType: .string) ?? "null"
print("CLIPBOARD_CHANGE")
fflush(stdout)
}
}while true