sync.lua
按下 Shift+F9 时将选中内容复制后同步到服务端。Shift+F8 时将服务端的内容粘贴到光标位置。
-- 远程剪贴板 hs.hotkey.bind( {'shift'}, 'f9', function() hs.eventtap.keyStroke({ "cmd" }, "c") local text = hs.pasteboard.readString() local url = 'https://upall.cn/pasteboard/' local headers = { ['Content-Type'] = 'x-www-form-urlencoded;charset=utf-8', } local code, body, headers = hs.http.post(url, text, headers) hs.alert.show("Pasteboard:" .. body) end ) hs.hotkey.bind( {'shift'}, 'f8', function() local url = 'https://upall.cn/pasteboard/' local code, body, headers = hs.http.get(url) hs.pasteboard.setContents(body) hs.eventtap.keyStroke({ "cmd" }, "v") end )
server
error_reporting(0); $method = $_SERVER['REQUEST_METHOD']; if ($method == 'POST') { $data = file_get_contents("php://input"); $data or exit(); #file_put_contents('./plain.txt', "\n\n>>>>" . date('Y-m-d H:i:s') . "\n", FILE_APPEND); #$r = file_put_contents('./plain.txt', $data, FILE_APPEND); $r = file_put_contents('./plain.txt', $data); echo $r; } else if ($method == 'GET') { echo file_get_contents('./plain.txt'); } else { exit("unknown mehtod: $method"); }