介绍
按下 Shift+F9 时将选中内容复制后同步到服务端。Shift+F8 时将服务端的内容粘贴到光标位置。
注意,加密方法 crypt() 在这里。
如果你没有服务器,可以试试这个文本存储服务:textdb.dev。
sync.ahk
autohotkey v2:
#Requires AutoHotkey v2.0
#SingleInstance Force
codepage := 65001
password := "your_password_here"
url := "https://upall.cn/pasteboard/"
+F9::
{
A_Clipboard := ""
Send("^c")
ClipWait
data := A_Clipboard
encrypted := crypt(data, password, true) ; 加密
data := encrypted ? encrypted : data
whr := ComObject("WinHttp.WinHttpRequest.5.1")
whr.Open("POST", url, true)
whr.SetRequestHeader("Content-Type", "text/plain")
whr.Send(data)
whr.WaitForResponse()
resText := whr.ResponseText
MsgBox(resText, , 2) ; 2秒后关闭
}
+F8::
{
whr := ComObject("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", url, true)
whr.Send()
whr.WaitForResponse()
data := whr.ResponseText
decrypted := crypt(data, password, false) ; 解密
data := decrypted ? decrypted : data
A_Clipboard := data
Send("^v")
}
autohotkey v1:
#NoEnv
#SingleInstance force
codepage = 65001
password := "your_password_here"
url := "https://upall.cn/pasteboard/"
+f9::
clipboard := ""
Send ^c
ClipWait
data := clipboard
encrypted := crypt(data, password, true) ; 加密
data := encrypted ? encrypted : data
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("POST", url, true)
whr.SetRequestHeader("Content-Type", "text/plain")
whr.Send(data)
whr.WaitForResponse()
resText := whr.ResponseText
MsgBox, 2000, , %resText% ; 2秒后关闭
return
+f8::
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", url, true)
whr.Send()
whr.WaitForResponse()
data := whr.ResponseText
decrypted := crypt(data, password, false) ; 解密
data := decrypted ? decrypted : data
clipboard := data
Send ^v
return
server
详见:同步剪贴板内容 Hammerspoon 中的 server 部分。
其它
注:移除加解密功能可以显著减小响应时间。