#include #include #include #include #include #include #include #include #include #include #include Global $g_idMemo, $g_hNext = 0 Global $Timeout = 10 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) 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", 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) 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 ;Msgbox ($MB_SYSTEMMODAL, "", "The following tmp" & @CRLF & ClipGet() , $Timeout) _FileWriteLog ($LogFile, $sData) ;Write Log to log file $IsPasted = False EndIf $CurrentTime = _NowCalc() If not $IsPasted Then If _DateDiff ('s',$CopyTime,$CurrentTime) > 10 and _DateDiff ('s',$CopyTime,$CurrentTime) < 12 Then $CMD = "echo off | clip";you start your script here RunWait(@ComSpec & " /c " & $CMD, @WindowsDir, @SW_SHOW) $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