Sign in to follow this  
Followers 0
gosu

Clipboard Logger v2

3 posts in this topic

#1 ·  Posted (edited)

Much thanks go to masvil and ezzetabi. They made the first clipboard logger here. I just added some more features, like a html-log.

; ----------------------------------------------------------------------------
;
; AutoIt Version: v3.0.103
; Language:       English
; Platform:       NT / 9X
; Author:         Ducksteina <Ducksteina@gmx.net>
;
; Description:
;    Logs Clipboard.
;
; Shift + F11         to view log of current day.
; Shift + Crtl + F11  to exit CBL.
; Shift + Win  + F11  to delete log of current day.
; Shift + Alt  + F11  to turn notification when logging on/off.
;
; ----------------------------------------------------------------------------


; ----------------------------------------------------------------------------
; Hotkeys
; ----------------------------------------------------------------------------
HotKeySet("+{F11}", "OeffneLog")
HotKeySet("^+{F11}", "BeendeProgramm")
HotKeySet("!+{F11}", "ToggleOutput")
HotKeySet("#+{F11}", "LoescheLog")


; ----------------------------------------------------------------------------
; Optionen
; ----------------------------------------------------------------------------
Opt ("TrayIconHide", 1)
Opt ("WinTitleMatchMode", 2)

; ----------------------------------------------------------------------------
; Variablen
; ----------------------------------------------------------------------------
$clipboard = ClipGet()
$dateiname = @ScriptDir & "\Log\" & @MDAY & "." & @MON & "." & @YEAR & ".html"
$erstesmal = 1
$output = 0

; ----------------------------------------------------------------------------
; Script
; ----------------------------------------------------------------------------
ToolTip("CB-Log: running!", 0, 0)
Sleep(2000)
ToolTip("", 0, 0)

If FileExists(@ScriptDir & "\Log\") = 0 Then
   DirCreate(@ScriptDir & "\Log\")
EndIf

While 1
   Sleep(100)
   
   $clipboard2 = ClipboardParsen()
   If $clipboard <> $clipboard2 And $clipboard2 <> '' Then
      $clipboard = $clipboard2
      $datei = FileOpen($dateiname, 1)
      If ErstesMal($dateiname) Then
         FileWriteLine($datei, "<html><!-- Clipboard-Log by Ducksteina --><pre>")
      EndIf
      FileWriteLine($datei, "<b>" & GetLogEntry() & "</b>")
      FileWriteLine($datei, $clipboard2 & @CRLF & @CRLF)
      If $output = 1 Then
         SoundPlay("C:\WINDOWS\Media\chimes.wav")
         ToolTip("CB-Log: Entry with the lenght of " & StringLen($clipboard2) & " chars saved!", 0, 0)
         Sleep(3000)
         ToolTip("", 0, 0)
      EndIf
      FileClose($datei)
   EndIf
Wend

; ----------------------------------------------------------------------------
; Funktionen
; ----------------------------------------------------------------------------
Func OeffneLog()
   If FileExists($dateiname) = 1 Then
      Run(@ComSpec & " /c start " & $dateiname, @ScriptDir, @SW_HIDE)
   Else
      MsgBox(64, "Clipboard Logger", "There is no log for the current day.")
   EndIf
EndFunc;==>OeffneLog

Func BeendeProgramm()
   $tempquestion = MsgBox(324, "Clipboard Logger", "Really exit Clipboard-Log?", 15)
   If $tempquestion = 6 Then
      Exit
   EndIf
EndFunc;==>BeendeProgramm

Func ToggleOutput()
   $tempquestion = MsgBox(324, "Clipboard Logger", "Activate sounds and tooltip when clipboard is logged?", 15)
   If $tempquestion = 6 Then
      $output = 1
   ElseIf $tempquestion = 7 Then
      $output = 0
   EndIf
   Global $output
EndFunc;==>ToggleOutput

Func LoescheLog()
   $tempquestion = MsgBox(324, "Clipboard Logger", "Really delete log of current day?", 15)
   If $tempquestion = 6 Then
      FileDelete($dateiname)
   EndIf
EndFunc;==>LoescheLog

Func GetLogEntry()
   $title = WinGetTitle("")
   Return @HOUR & ":" & @MIN & ":" & @SEC & " [" & $title & "]:"
EndFunc;==>GetLogEntry

Func ClipboardParsen()
   $temp = ClipGet()
   $temp = StringReplace($temp, "&", "&amp;")
   $temp = StringReplace($temp, "<", "&lt;")
   $temp = StringReplace($temp, ">", "&gt;")
   Return $temp
EndFunc;==>ClipboardParsen

Func ErstesMal($dateifuerfunc)
   $chars = ""
   $datei2 = FileOpen($dateifuerfunc, 0)
   If $datei2 = -1 Then
      MsgBox(0, "Error", "Unable to open file.")
      Exit
   EndIf
   While 1
      $chars = $chars & FileRead($datei2, 1)
      If @error = -1 Then ExitLoop
   Wend
   FileClose($datei2)
   If StringInStr($chars, "<html><!-- Clipboard-Log by Ducksteina --><pre>") = 1 Then
      Return 0
   Else
      Return 1
   EndIf
   Return $chars
EndFunc;==>ErstesMal

Enjoy!

Edited by gosu

[quote name='d2hacker88' date='Jan 6 2005, 05:10 PM']Can someone please help me out with autoit like gimme a link on how to use it cause i have no experience with computer languages and i'd like to make a program with autoit in order to empress my computer teacher.[right][snapback]52215[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

Much thanks go to masvil and ezzetabi.

Not at all :">

There is a log path error, SHIFT + F11 can't found "clip" file in script dir (generated log is in \log\date.html).

Edited by masvil

Share this post


Link to post
Share on other sites

Not at all  :">

There is a log path error, SHIFT + F11 can't found "clip" file in script dir (generated log is in \log\date.html).

<{POST_SNAPBACK}>

Hm? It´s working for me. Maybe you have to create the folder if it does not exist.

[quote name='d2hacker88' date='Jan 6 2005, 05:10 PM']Can someone please help me out with autoit like gimme a link on how to use it cause i have no experience with computer languages and i'd like to make a program with autoit in order to empress my computer teacher.[right][snapback]52215[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0