Traver REALbasic for Windows: The Blog

REALbasic discussion and programs specifically for Windows (and some discussion of differences between REALbasic and Visual Basic).

Tuesday, April 18, 2006

CollectClips: A Windows Clipboard Utility

Whenever one copies an item of text to the Windows clipboard, ordinarily the new item replaces what was there earlier. But suppose you want to "collect the clips," so to speak?

My CollectClips utility is a simple way to do that. I put it together when I was using a scanner to scan text and the associated OCR program copied the related text to the Windows clipboard. Since I didn't want to bother with pasting the copied text in the Windows clipboard to some safe place each time before I did a new scan, I decided to write this utility.

There are no especially impressive "tricks" here. I do use a Timer to accomplish my purpose, so the program does provide an example of one way in which the Timer may be useful, but that's about it.

The program works automatically. The only things you need to do are to start up CollectClips when you want to start saving things from the Windows clipboard and to use the File menu to Save As Text the collected clips before you Exit from the CollectClips program.

Here's where you can find the source code for the program (

Feel free to improve upon the program (but please send me a copy of the improved result). Enjoy!

Barry Traver


At 7:08 AM, Blogger Steve Garman said...

Nice utility, but there are a couple of small points I'd make about the Timer1.Action event handler.

I'd hesitate to keep the clipboard open while you mess about with strings. That's very time consuming.
Remember the clipboard's locked while it's open and your OS has preemptive threads.

I also can't see any need for all the duplicated code based on whether mainbuffer starts empty or not.

I'd have thought all the code you need is:

Sub Action()
Dim c As Clipboard
Dim newText As String
Dim Count1 As Integer
Dim EOL As String
EOL = Left(EndOfLine,1)
c = New Clipboard
If c.TextAvailable Then
newText = c.Text
If newText <> FormerText Then
MainBuffer = MainBuffer + EOL + newText + EOL _
+ "________________" + EOL
EditField1.Text = MainBuffer
Count1 = CountFields(EditField1.Text, EOL) - 4
EditField1.Scrollposition = Count1
FormerText = newText
Self.Title = FormerText + " " + newText + " " + "B " + Str(Count1)
End If
End If

End Sub


Post a Comment

<< Home