Traver REALbasic for Windows: The Blog

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

Sunday, April 23, 2006

More on CollectClips: A Windows Clipboard Utility

Somehow - while "moderating comments" on this blog - I managed to mess up and delete a recent comment from Steve Garman, so I'm making it the main contents of this entry, where it should be read by more people anyway.
Here's what Steve had to say:
 __________________________________________
/
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
      c.Close
      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
\__________________________________________

I appreciate the comments from Steve, because I'm primarily an "idea" person and often need all the help I can get from friends who have more professional expertise than I have. That is, I have lots of ideas for interesting programs and can sometimes (not always) come up with enough code to prove that the idea can become a practical reality, but I often rely on others to make the code more professional and polished.

Barry Traver

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 (Collect2Clips.zip):

http://traver.org/traverrbw

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

Barry Traver