-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClipBoardMonitor.ahk
38 lines (32 loc) · 1005 Bytes
/
ClipBoardMonitor.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#NoTrayIcon
#Persistent
#SingleInstance, force
SetWorkingDir % A_ScriptDir
CoordMode, ToolTip, Screen
; will only show the top %CharacterCount% characters
Global CharacterCount := 300
Global TEXTS_dir := A_WorkingDir "\cache\texts\"
OnClipboardChange("ClipChanged")
Return
ClipChanged(Type) {
; Contains one of the following values:
; 0 if the clipboard is now empty;
; 1 if it contains something that can be expressed as text (this includes files copied from an Explorer window);
; 2 if it contains something entirely non-text such as a picture.
Try {
If (Type = 1)
{
s := SubStr(Clipboard, 1, CharacterCount)
ToolTip % "[INFO] " StrLen(ClipBoard) " characters copied!`n" s
If FileExist(TEXTS_dir)
FileAppend % Clipboard, % TEXTS_dir . A_Now . ".txt"
}
}
Catch e {
ToolTip % "[ERROR] "
}
SetTimer, ToolTip, -800 ; show a ToolTip for at least 800ms
}
ToolTip:
ToolTip
Return