#include #include #include #include #include #include #include #include #include #include #include Global $g_idMemo, $g_hNext = 0 Global $CopyTime Global $CurrentTime Global $LogDir = @UserProfileDir & "\Appdata\Roaming\Cliplog" Global $LogBackup = @UserProfileDir & "\Appdata\Roaming\Cliplog\Backup" Global $IsPasted = True Local $LogFile = @UserProfileDir & "\Appdata\Roaming\Cliplog\Cliplog.txt" Local $FileCreateDate = FileGetTime($LogFile, 1) Global $LastText = "" If FileExists($LogDir) Then If FileExists($LogFile) Then If $FileCreateDate[1] < @MON Or $FileCreateDate[0] < @YEAR Then FileMove(@UserProfileDir & "\Appdata\Roaming\Cliplog\Cliplog.txt", @UserProfileDir & "\Appdata\Roaming\Cliplog\Cliplog_" & @MDAY & @MON & @YEAR & ".txt", 8) If FileExists($LogBackup) Then FileMove(@UserProfileDir & "\Appdata\Roaming\Cliplog" & "\*.txt", @UserProfileDir & "\Appdata\Roaming\Cliplog\Backup", $FC_OVERWRITE + $FC_CREATEPATH) Else DirCreate($LogBackup) FileMove(@UserProfileDir & "\Appdata\Roaming\Cliplog" & "\*.txt", @UserProfileDir & "\Appdata\Roaming\Cliplog\Backup", $FC_OVERWRITE + $FC_CREATEPATH) EndIf EndIf Else Example() EndIf Else DirCreate($LogDir) EndIf Example() Func Example() Local $hGUI ; Create GUI $hGUI = GUICreate("Clipboard Cleaner -- AON", 600, 400) $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOWMINIMIZED) ; Initialize clipboard viewer $g_hNext = _ClipBoard_SetViewer($hGUI) GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN") GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD") MemoWrite("Clipboard utility ....: AON") MemoWrite("Clipboard owner ....: " & @UserName) MemoWrite(":...............................................................................:") ; Loop until the user exits. Local $GetMsg = True While 1 Local $currMsg = GUIGetMsg() Clear() ; if $currMsg = $GUI_EVENT_CLOSE then $GetMsg = False WEnd ; Shut down clipboard viewer _ClipBoard_ChangeChain($hGUI, $g_hNext) EndFunc ;==>Example ; Write message to memo Func MemoWrite($sMessage = "", $IsDate = True) If $IsDate Then GUICtrlSetData($g_idMemo, _Now() & " " & $sMessage & @CRLF, 1) Else GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndIf EndFunc ;==>MemoWrite ; Handle $WM_CHANGECBCHAIN messages Func WM_CHANGECBCHAIN($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg ; Show that message was received MemoWrite("***** $WM_CHANGECBCHAIN *****") ; If the next window is closing, repair the chain If $wParam = $g_hNext Then $g_hNext = $lParam ; Otherwise pass the message to the next viewer ElseIf $g_hNext <> 0 Then _SendMessage($g_hNext, $WM_CHANGECBCHAIN, $wParam, $lParam, 0, "hwnd", "hwnd") EndIf EndFunc ;==>WM_CHANGECBCHAIN ; Handle $WM_DRAWCLIPBOARD messages Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg ; Display any text on clipboard MemoWrite(_ClipBoard_GetData()) ; Pass the message to the next viewer If $g_hNext <> 0 Then _SendMessage($g_hNext, $WM_DRAWCLIPBOARD, $wParam, $lParam) EndFunc ;==>WM_DRAWCLIPBOARD Func Clear() If _IsPressed("11") And _IsPressed("56") Then If Not $IsPasted Then ;$CMD = "echo off | clip" ;you start your script here ;RunWait(@ComSpec & " /c " & $CMD, @WindowsDir, @SW_SHOW) ClipPut("") EndIf $IsPasted = True Else If _IsPressed("11") And _IsPressed("43") Then Global $sData = ClipGet() ; Retrieve the data stored in the clipboard. $CopyTime = _NowCalc() ; Store copytime to variable If $LastText <> $sData Then _FileWriteLog($LogFile, $sData) ;Write Log to log file $IsPasted = False $LastText = $sData EndIf $CurrentTime = _NowCalc() If Not $IsPasted Then If _DateDiff('s', $CopyTime, $CurrentTime) > 4000 And _DateDiff('s', $CopyTime, $CurrentTime) < 4002 Then ;$CMD = "echo off | clip" ;you start your script here ;RunWait(@ComSpec & " /c " & $CMD, @WindowsDir, @SW_SHOW) ClipPut("") $IsPasted = True EndIf EndIf If _IsPressed("11") And _IsPressed("10") And _IsPressed("23") Then Exit EndIf EndIf Break(0) ; Disable Break/Pause/Exit of script GUIGetMsg() ; to cool out CPU when CTRL+V is not pressed. It was not kept in loop of while so that it can be called everytime but not when CTRL+ V is pressed.If not added then CPU usage will be 25% EndFunc ;==>Clear