Sign in to follow this  
Followers 0
masvil

Clipboard logger

4 posts in this topic

#1 ·  Posted (edited)

A clipboard logger, my first script here.

Express opinion and/or suggest modifies, please :idiot:

Can it effort CPU?

$first = 0
While 1
   $clip = ClipGet()
   If @error = 0 And $first = 0 Then;so that it logs also FIRST content
      $title = WinGetTitle("")
      $file = FileOpen(@ScriptDir & "\cliplog.txt", 1)
      FileWriteLine($file, "[" & $title & "] - " & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC)
      FileWriteLine($file, $clip & @LF & @LF)
      FileClose($file)
      $first = 1
   EndIf
   
   Sleep(100)
   
   $clip2 = ClipGet()
   If $clip <> $clip2 Then
      $title = WinGetTitle("")
      $file = FileOpen(@ScriptDir & "\cliplog.txt", 1)
      FileWriteLine($file, "[" & $title & "] - " & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC)
      FileWriteLine($file, $clip2 & @LF & @LF)
      FileClose($file)
   EndIf
Wend
Edited by masvil

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Added: F11 hotkey to open log file

HotKeySet("{F11}", "ViewLog")

$first = 0
While 1
   $clip = ClipGet()
   If @error = 0 And $first = 0 Then
      $title = WinGetTitle("")
      $file = FileOpen(@ScriptDir & "\clip.txt", 1)
      FileWriteLine($file, "[" & $title & "] - " & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC)
      FileWriteLine($file, $clip & @LF & @LF)
      FileClose($file)
      $first = 1
   EndIf
   
   Sleep(100)
   
   $clip2 = ClipGet()
   If $clip <> $clip2 Then      
      $title = WinGetTitle("")
      $file = FileOpen(@ScriptDir & "\clip.txt", 1)
      FileWriteLine($file, "[" & $title & "] - " & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC)
      FileWriteLine($file, $clip2 & @LF & @LF)
      FileClose($file)
   EndIf
Wend

Func ViewLog()
   Run(@ComSpec & " /c start clip.txt", @ScriptDir)
EndFunc;==>ViewLog
Edited by masvil

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Interesting, but for Autoit limitations it can hold only text. I can't keep many copied files or pictures.

Also, use

Func ViewLog()
  Run(@ComSpec & " /c start clip.txt", @ScriptDir,@sw_hide)
EndFunc;==>ViewLog

so it does not flash a black screen when using F11.

I woud do this way:

HotKeySet("{F11}", "ViewLog")

$clip = ClipGet()

While 1
  Sleep(100)
  
  $clip2 = ClipGet()
  If $clip <> $clip2 and $clip2 <> '' Then
     $clip = $clip2
     $title = WinGetTitle("")
     $file = FileOpen(@ScriptDir & "\clip.txt", 1)
     FileWriteLine($file, "[" & $title & "] - " & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC)
     FileWriteLine($file, $clip2 & @LF & @LF)
     FileClose($file)
  EndIf
Wend

Func ViewLog()
  Run(@ComSpec & " /c start clip.txt", @ScriptDir,@sw_hide)
EndFunc;==>ViewLog

About CPU, it should be not a problem.

Edited by ezzetabi

Share this post


Link to post
Share on other sites

I woud do this way:

Me too :idiot:

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