dotfiles
My PC Dotfiles & Websitegit clone https://github.com/maydayv7/dotfiles
files/windows/scripts/clipboard.ahk (1450B)
1#Requires AutoHotkey v2.0
2Persistent
3
4; Configuration
5SyncDir := "C:\Sync\Clipboard"
6PcFile := SyncDir "\pc_clip.txt"
7AndroidFile := SyncDir "\android_clip.txt"
8global LastAndroidMod := 0
9
10; ==============================================================================
11; PC to Android (Push -> Ctrl + Alt + C)
12; ==============================================================================
13^!c:: {
14 if (A_Clipboard != "") {
15 try {
16 if FileExist(PcFile)
17 FileDelete(PcFile)
18 FileAppend(A_Clipboard, PcFile, "UTF-8")
19 ToolTip "Sent to Android!"
20 SetTimer () => ToolTip(), -1500
21 }
22 } else {
23 ToolTip "Clipboard is empty or not text!"
24 SetTimer () => ToolTip(), -1500
25 }
26}
27
28; ==============================================================================
29; Android to PC (Pull)
30; ==============================================================================
31SetTimer CheckAndroidClip, 1000
32
33CheckAndroidClip() {
34 global LastAndroidMod
35 if FileExist(AndroidFile) {
36 currentMod := FileGetTime(AndroidFile, "M")
37 if (currentMod != LastAndroidMod) {
38 LastAndroidMod := currentMod
39 try {
40 newClip := FileRead(AndroidFile, "UTF-8")
41 A_Clipboard := newClip
42 ToolTip "Received from Android!"
43 SetTimer () => ToolTip(), -1500
44 }
45 }
46 }
47}