I wanted to log clipboard content whenever it changes, so I created this code:
#Persistent
FileEncoding, UTF-8
OnClipboardChange("ClipChanged")
return
ClipChanged(Type) {
now := A_Now
FormatTime, time, now, dd.MM.yyyy HH:mm:ss
FileAppend, % Format("{} '{}'`n", time, Clipboard), D:\clipboard_log.txt
}
Now, I would like to ignore scenarios when clipboard has been changed by me. I want to log clipboard changes made only by external applications. I came up with an idea:
#Persistent
FileEncoding, UTF-8
OnClipboardChange("ClipChanged")
global clipChangedByMe := false
return
ClipChanged(Type) {
if (clipChangedByMe)
{
clipChangedByMe := false
}
else
{
now := A_Now
FormatTime, time, now, dd.MM.yyyy HH:mm:ss
FileAppend, % Format("{} '{}'`n", time, Clipboard), D:\clipboard_log.txt
}
}
^c::
clipChangedByMe := true
Clipboard := ClipboardAll
return
For some reason, ClipChanged event is not fired after line: Clipboard := ClipboardAll. Whats wrong there?