ClipUtil

A Simple Clipboard conversion utility for Windows

David W. Poole, Jr.

Last updated 2003-05-22 19:04:06 Thursday
A Palm OS version is here.


Contents

Introduction / Background

Example/Introduction (This section is incomplete, and reading is not recommended at this time; skip this section)

Notes on Carriage Returns, Line Feeds, New Lines, and Form Feeds

Known Issues

Release notes from 2003-05-22 19:04:06 Thursday
Release notes from 2003-05-21 07:02:33 Wednesday
Release notes from 2003-05-19 08:33:20 Monday
Release notes from 2003-05-08 00:51:46 Thursday
Release notes from 2003-05-05 19:41:39 Monday
Release notes from 2003-05-03 18:44:44
Release notes from 2003-04-29 08:03:34
Release notes from 2003-04-28 15:57:13
Release notes from 2003-04-25 16:03:24
Release notes from 2003-04-17 19:37:42


Download ClipBoardTool.zip

Note: added drag-and-drop functionality to the program, to allow conversion of Palm DOC files to text format and vice-versa. Drag a text file (or files) into the window, and it will produce in the same directory Palm DOC equivalents. Drag Palm DOC files into the window, and it produces the corresponding text file.



Example/Introduction (This section is incomplete, and reading is not recommended at this time; skip this section)

ClipUtil was written for a variety of reasons, mainly related to laziness. ClipUtil takes some functions that I used various tools to perform on files, and combined them in one location, for use with the clipboard. As some of these functions are required by me on both the Windows and Palm OS platform, there is some common functionality between the two programs.

2003-05-06 17:08:53 Tuesday:

Interestingly enough, I found a web site long after I wrote this that explains why I wrote the application:

http://www.coders-central.org/project_advice.htm

People quite regularly ask for advice about what kind of project they should undertake to extend and improve their programming skills. Many (if not most) replies they get from this tend to be fairly specific -- people reply with everything from mathematical puzzles to major undertakings like designing and implementing a new language or operating system.

My advice is to sit back and think for a little bit, and try to think of something you do on the computer fairly frequently, that seems to end up slower, more difficult or more annoying than it seems like it should be. This can be any of a huge variety of things, though if you're starting out, it's usually best to try to deal with relatively simple problems. In most cases, it's best to think of things that are slow or annoying because you have to carry out a number of operations manually, but always or nearly always do exactly the same things in the same order.

Once you've thought of some set of operations you carry out in a fairly specific sequence on regular basis, you can write code to automate that sequence of operations.

This approach has two advantages, at least in my experience. It's a project that really interests you, so you're more likely to continue working on it until it's really useful and usable, and second you might be motivated to keep working on it and try to do the job well, even when you figure out that you've taken on a little more than you're completely secure with. This way, even though you started out with the intent of practicing things you already know, you end up learning a few new things along the way as well - which is generally a good thing.

ClipUtil for Windows operates entirely on the clipboard, and properly defined, is a clipboard viewer. However, the only format of clipboard information that it displays is textual. This is because ClipUtil does nothing but manipulate text in an automated fashion. Please note that there is no undo feature with this program as of yet. As such, if you've cut text contents from an application, as opposed to copy, changes you make to the clipboard can result in the loss of data. It is advised that you experiment with this program on some test data to get a feel for it's functionality.

For the purposes of providing examples of the program's usage, it is assumed in most cases that the clipboard contains the text within the box below:

ClipUtil Test Text
200302232134
20030223221717
20030223221718
20030223221720
20030223221722
20030223221724
20030223221726
20030223221728
20030223221730
20030223221731
20030223221733
20030223221735
20030223221737
20030223221739
20030223221741
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
22233344455566677778889999

      Some leading white space on this line.
Some trailing white space on this line.

 

Some extra new lines before this line.

 

a8 b8 c8 d8 e8 f8 g8 h8
a7 b7 c7 d7 e7 f7 g7 h7
a6 b6 c6 d6 e6 f6 g6 h6
a5 b5 c5 d5 e5 f5 g5 h5
a4 b4 c4 d4 e4 f4 g4 h4
a3 b3 c3 d3 e3 f3 g3 h3
a2 b2 c2 d2 e2 f2 g2 h2
a1 b1 c1 d1 e1 f1 g1 h1

The text at the bottom of the sample clipboard listed above represents the coordinates used for describing squares on a chessboard. There are some functions included in ClipUtil that allow for automated manipulation of coordinates.

Notes on Carriage Returns, Line Feeds, New Lines, and Form Feeds (composed prior to 2003-04-13 17:34):

Different computer systems store text in different ways. Without getting too technical, there are times when various conversions need to be performed to make text suitable for use on another system. A little information regarding this may be prudent. Furthermore, it may be handy to draw an analogy to the old mechanical typewriters in doing this.

A Line Feed is a code that specifies that the page is to be advanced one line, without any motion of the type head. This is akin to turning the platen on a typewriter by the knob. Subsequent characters output would appear one line below, starting in the column after the last printed column the line above, not at the first column!

A Carriage Return is a code that specifies that the type head is to return to the first column of the page, without the platen being advanced at all. Subsequent characters output would be produced over (over-printed) the previously produced line.

A New Line is a pair of codes, specifically a Carriage Return and a Line Feed, that combines the effects. This is similar to hitting the bar on the carriage of a manual typewriter, that returns the platen to the first column and advances the platen a specified number of limes simultaneously. Subsequent output is produced starting in the first column of the next line from where the previous output was placed. This is typically the desired functionality!

A Form Feed is a code that specifies that the typewriter should eject the page and begin subsequent output on the next page. For use with the Clipboard and the memo pad functionality of the Palm desktop software for Microsoft Windows, a Form Feed is used to specify a new memo. To a major degree, it's the issue of form feeds with respect to the Palm Desktop that this application was written.

Different systems use different ways to mark the end of a line of text and the beginning of the next. The MS-DOS/Windows world uses a New Line, which technically is more appropriate than just using a Line Feed or a Carriage Return. From an efficiency point of view, however, this makes life more complicated for programmers, plus increases by a very minor degree the amount of space required to store text on a system. Some systems use a simple Carriage Return, while others use a Form Feed. Yes, it is a mess!

ClipUtil provides some functionality to provide conversions between these different types of systems.

Introduction / Background composed 2003-04-13 17:34

ClipUtil started life as an experiment for me to gain some Win32 programming experience. I wanted the experience gained to be gained doing something personally useful, as I felt this would prompt me to pursue it with a greater passion.

ClipUtil is also known as ClipboardTool.exe; the confusion with the names is due to the fact that I've also implemented a stripped down version of this program for the Palm OS, which I refer to as ClipUtil.prc.

ClipUtil is alpha quality software; this stuff isn't quite ready for prime time. There are menu features that aren't implemented, or that don't work correctly. In fact, there are some menu features that work a little differently (sometimes correctly, sometimes incorrectly) depending on the program that placed the contents into the clipboard. I am currently working to resolve these inconsistencies, but needless to say the program is definitely buggy. Thus, you are advised to experiment greatly with any particular version of it. Of particular noteworthiness is that some of the remove and replace options occasionally will add or remove information at the end of the clipboard's contents. With this warning in mind, we'll proceed to describe it's functionality somewhat. Also bear in mind that ClipUtil behaves strangely with some application's use of the Clipboard. For example, when ClipUtil is running, Adobe's PDF viewer doesn't seem to like putting text on the clipboard. Due to it's inconsistencies, ClipUtil's reason for being posted to the web is not for others, but so that I can get to it when I'm at a machine that doesn't have it installed.

ClipUtil has an appending feature that makes it handy for accumulating textual snippets. When activated, any "cut" or "copy" clipboard operations from another application will result in the current selection being appended to the end of any existing clipboard contents. This makes it handy if you're collecting snippets of information about a given subject from different electronic resources. Unfortunately, the Append mode must be active when you perform your first copy.

Known Issues

Conversion of text files to Palm DOC files sometimes cause RTF (Rich Text Format) control codes to be embedded in the resultant DOC file. My assumption is that Microsoft's standard IO library is *not* exactly compatible with the ANSI definition, and that for some reason(s) they decide to incorporate RTF during ASCII file read operations. The resolution is to recode the conversion code (of which I am not the author) to use the WinAPI subset for file IO as opposed to using stdio; problematic because there is some functionality present in the ANSI file library that I haven't found the comparable WinAPI call for.

Doc files still problematic; I believe this may be a problem with DocReader, and not ClipUtil/MakeDoc7 however. More research is required.

The networking functions do not work, plain and simple. They work to a very minor degree, but not enough to consider using. These were actually just some experiments gone awry to begin with.

The vertical scroll bar sometimes appears when it's not needed, and sometimes (though far more rarely) disappears when it is needed.

Release notes from 2003-05-22 19:04:06 Thursday

Modified to allow a left double click in the window to always toggle the window size.

Added menu functionallity for some of the more common display options available, to simplify the process of quickly changing one setting.

Modified it to support dragging the window by clicking in the client area, as without a caption bar moving the window isn't possible.

Got dialing logic somewhat functional.

Release notes from 2003-05-21 07:02:33 Wednesday

The Auto Clean functionallity has been implemented, and appears ok.

Added right click handler in client window to invoke a pop-up menu.

Added logic to toggle displaying the menu bar in the main window.

Swapped the functionallity of the left and right mouse buttons on the icon in the system tray. This provided greater consistency with the main window as well as with other system tray apps.

Implemented an option to allow the user to select between a normal application style window and a tool application style window.

Added an option to the pop-up menu to toggle window status between maximized and restored; no other way to do it when you have the option to use the left mouse button turned off, and no normal application bar.

Added a "sanity check" value to the Shell Execute options, as I accidentally tried to launch a ton of files and the system didn't take too kindly to that. Added logic to support adjusting and saving the shell execute sanity check value.

Fixed the initial display when the clipboard changes.

Seem to have got the problem straightened out with scroll bars remaining in the window after the clipboard is emptied.

Release notes from 2003-05-19 08:33:20 Monday

Added an option to allow copying the file name(s) of dragged file(s) to the clipboard.

I think I have the scroll bars functional with the text, and I also cured a problem that resulted in displaying textual clipboard contents when I began hammering in the "skeleton" scroll bar code.

Haven't made much progress on the scroll bars, but I have got a split status window somewhat functional.

I addressed the split status window issues earlier, as well as made some progress to making the progress bar for drag-and-drop operations a little more asthetically appealing.

Release notes from 2003-05-08 00:51:46 Thursday

Added a appending method that didn't have any seperator character(s).

Added an option from the new dialog screen to allow the user left clicking in the window to toggle between restored and maximized views.

Got some icon madness resolved.

Move the splash screen disposal logic from the last part of the initialization code to the timer code responsible for flashing the icon in the system tray, leaving the screen up long enough to read, but without having to put an unneccesary sleep() in.

Add mode to activate the monitor low power and monitor power off modes.

Smoother/faster scrolling functional.

Added tabulated text output so source code wouldn't look so funky.

Added last time used and total times used tracking to the clips to provide extra sorting options for compacting the menu. This has the unfortunate side effect of invalidating existing clipping files, but since no one is using this I don't think there will be much of a fuss.

Release notes from 2003-05-05 19:41:39 Monday

Added support for different types of separators when appending mode active.

Eliminated the annoying flicker of the status bar during scrolling.

Visibility toggling with the right mouse button on the system tray fixed.

Added AutoShell functionality; use with extreme caution. :-)

Added "copyto=" command line processing, although I don't have an automated way to add the explorer extensions.

The mouse wheel in conjunction with the left mouse button now increases and decreases the font size, similar to the manner in which DocReader does. Also, the font size is saved in the profile, making it persistent. Still to be done is saving the font style itself, though.

Modified the clipping storage menu to be half of it's original width, to expedite menu redraws and reduce user error.

Added a rudimentary options dialog box to prevent having to run back and forth from menu to menu when changing multiple options. Status Bar and Tool Bar options are not yet functional.

Reworked the page somewhat; this includes:

Added a "Known issues" section. This one section will contain all known issues with the application.

Reworked the section regarding mouse usage, as mouse usage has been changed greatly due to discussion on the issue.

Modified the page to have the revision history sorted in descending date order as opposed to ascending date order; a historical timeline of applications is usually best read backward.

Release notes from 2003-05-03 18:44:44

Modified the window position save logic (actually the restore logic) to make sure the window wouldn't be presented off-screen. Unfortunately the drawback is that the always on top setting is affected in these rare circumstances.

Got the stock retrieval CSV code functional again, and updated the display window routines for it.

Added a feature to minimize, maximize, and restore all windows.

I have some rudimentary scrolling functional with the program, through the use of the wheel mouse button.

After downloading a nice WinAPI help file as well as Petzold's book, I have scroll bar functionallity implemented. It's wired to the keyboard as well as the mouse wheel button.

Release notes from 2003-04-29 08:03:34

Reworked the About dialog a little bit.

Reworked the minimize/show window/system tray/task bar logic a little bit (again).

Added some keyboard support; insert, delete, escape, and scroll lock keys provide some functionality.

Took the "compact storage menu/no sort" option out, as qsort() re-arranges items even when told not too (I forgot about this anomaly, but it's been 17 years since I studied the workings of qsort()). On second thought, I should have left this, and in conditions where two clippings compare equally, I should use their address as a comparison item.

Added back the no sorting option to the clip compaction option.

In a bit of an experiment, I now have a floating non-modal dialog box, used for a status display. Not that it's of any use to the application, but it's there.

To prevent multiple instances of the app from running simultaneously, a mutex was incorporated.

Release notes from 2003-04-28 15:57:13

Added better sorting (or compacting) options for the clip storage facility.

Reworked the window class to facilitate better (and more normal) behavior when minimizing/showing the window, and with interaction with the system tray.

Release notes from 2003-04-25 16:03:24

Added the ability to store up to 20 "clippings" and recall them as needed.

Did some general bug fixes.

Release Notes from 2003-04-17 18:26:23

ClipUtil and this documentation have been updated. The warnings present in the second introduction are still applicable. Some of the problematic code has been corrected, and the application is much more stable, far less erroneous, and more complete. This release is made due to these and other enhancements.

New features in this release:

The application now minimizes to the system tray, and uses a series of different icons to indicate the status of the program. These icons are described shortly. Once familiar with ClipUtil's operation, a majority of it's functionality can be received without the use of a normal application window.

Yes, it still lacks scroll bars. :-(

"Normal" system tray indicator.
Appending mode indicator; if ClipUtil's append feature is enabled, the system tray will indicate this by periodically flashing this icon.
Appending mode indicator; if ClipUtil's append feature is enabled, the system tray will indicate this by periodically flashing this icon.
Palm desktop memo pad safe indicator; if the content contained in the clipboard will fit within the Palm Desktop's Memo pad during a paste operation, this icon will flash periodically.
Palm desktop memo pad safe indicator; if the content contained in the clipboard will fit within the Palm Desktop's Memo pad during a paste operation, this icon will flash periodically.

In order for the clipboard to be considered safe for pasting into the Palm Desktop's Memo Pad, the memo must either be less than 4096 bytes in size, or have a form feed characters no greater than 4096 bytes apart or from the beginning or end of the clipboard (ie, the clipboard is implied to have form feed characters at the beginning and end of it's content). The Palm Desktop application uses a form feed character to specify the end of one memo and beginning of another. You can look at either of ClipUtil's status messages to determine how many form feeds are in the clipboard; they are indicated by the "FF: " number. If ClipUtil's tray icon indicates that the clipboard's contents are Palm desktop memo pad safe, you can tell how many memos will appear in the desktop by looking at the "FF: " number and adding 1 to it.

A major portion of my desire to implement this utility was to facilitate copying and pasting of information from various sources, such as the web, and being able to quickly and easily paste the relevant content into a format that would be better for the Palm Desktop's Memo Pad. I also use date and time stamps to record these "clippets", and I think it to be the electronic equivalent of highlighting with a marker. For example, I want to keep some content from the page(s) I read, but discard the "bulk" stuff that's of no importance, such as links to other locations. For example, during a recent job search I encountered the following information that I wanted to retain:

2003-04-08 22:24:56 Job Search
Tuesday

http://app.cvtracer.com/public/965725011/jobpostings/1693.htm

VC++ Programmer1693
Posting Date: 03/19/2003
Type: Permanent
Description: Software Engineer-C++, VC++ (2 positions) Technical requirements: Strong C++ foundation. Though they will work primarily in VC++ they must understand the foundations of C++ as all the underlying systems are in C++. They must have experience in network programming. Looking for skills in the ANSI standard, STL (Standard Template Libraries,) BSD Sockets (or WinSock or similar tool,) WIN 32 API. The team needs this person to be a real expert in Windows programming-with VC++ and MFC. They will however be interfacing to a Linux system so need Linux skills. Major challenges now are cleaning up and making more stable the trading interface. This company traded 100 million shares of stock for the first time this May. The system can not crash. The GUI guys get blamed even if it is not their fault as their part is most visible to the users. Customer-orientation and troubleshooting skills will be paramount. Programs must execute immediately. Data feeds from external sources are parsed into these systems and must be visible to the users within 1 second or less.
Salary: 45-95K + bonus
Start Date: March-April 2003
Position potential: Unlimited. Ask for details.

Contact
Name: Gil
Phone: 803-771-9977
Email: [email protected]

While I was surfing the page originally located here, I used the middle mouse button on the ClipUtil's system tray icon to toggle ClipUtil until it's tray icon indicated it was appending, which meant it had prepended the current date and time. I then clicked in Explorer's address bar, and then right clicked and copied the address to the clipboard, which ClipUtil appended to the previous date and time stamp. I then went through the page, selecting the important portions of the page to keep, and copying each to the clipboard, which was appended to the previous contents. When the process was complete, I used ClipUtil's Cleanup, General Text, Palm Memo Pad Ready feature to make the contents more "memo pad" friendly.

If I decide to go back to this page, I can select either the address, or the entire memo itself, and copy it to the clipboard. I can then use ClipUtil's Shell Clipboard option to launch the page.

In addition, due to the experimental nature under which this program was created, some features have been added that don't make sense for a Clipboard viewer type application. These options include CD drawer control.

Mouse Use in ClipUtil

Window

Left clicking in the ClipUtil window does nothing at present.

Middle clicking in the ClipUtil window turns append mode off.

Right clicking in ClipUtil window does nothing at present.

System Tray

Left clicking on the ClipUtil tray icon brings up a menu for ClipUtil. A majority of the functions available to ClipUtil through it's windowed menu are available through it's tray icon menu; however, the tray icon menu's options are arranged differently to provide for hopefully more efficient use.

Middle clicking on the ClipUtil tray icon toggles the append mode, and is a short cut to the middle mouse button being clicked in ClipUtil's window.

Right clicking on the ClipUtil tray icon displays or hides the ClipUtil window. Hiding ClipUtil removes it from the task bar, which hides it from the "Alt-Tab" list, forcing all subsequent interaction through ClipUtil's system tray icon.

Some of ClipUtil's commands

Shell The Clipboard

This option attempts to launch any web addresses and/or document names that might be present in the clipboard. This allows you to create a clippet like the following, and launch multiple programs simultaneously.

FileSet: CDs.

"C:\Program Files\cspy151\CloneSpy.exe"
"C:\Program Files\Ahead\Nero\nero.exe"
"C:\Program Files\FillCD\FillCD.exe"

Using the option with the clipboard containing the above text would launch the three applications listed in the clipboard.

Append

This option switches ClipUtil back and forth between append mode. Any new textual content copied to the clip board when append mode is active is appended to the end of any prior textual content.

Delete

Deletes the contents of the clipboard; handy if you get lost with the Append feature.\

General Cleanup

Provides some commonly used sequences of instructions I use to format the Clipboard's textual contents in a manner that is handy for me. All examples use the example contents of the clipboard as previously provided.

Palm Memo Pad Ready

All occurences of more than two new lines are converted to two new lines, as well as all trailing spaces is removed from the end of lines.

ClipUtil Test Text
200302232134
20030223221717
20030223221718
20030223221720
20030223221722
20030223221724
20030223221726
20030223221728
20030223221730
20030223221731
20030223221733
20030223221735
20030223221737
20030223221739
20030223221741
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
22233344455566677778889999
Some leading white space on this line.
Some trailing white space on this line.

Some extra new lines before this line.

a8 b8 c8 d8 e8 f8 g8 h8
a7 b7 c7 d7 e7 f7 g7 h7
a6 b6 c6 d6 e6 f6 g6 h6
a5 b5 c5 d5 e5 f5 g5 h5
a4 b4 c4 d4 e4 f4 g4 h4
a3 b3 c3 d3 e3 f3 g3 h3
a2 b2 c2 d2 e2 f2 g2 h2
a1 b1 c1 d1 e1 f1 g1 h

Single Spaced

All continual occurences of multiple new lines are replaced with two new lines.

ClipUtil Test Text
200302232134
20030223221717
20030223221718
20030223221720
20030223221722
20030223221724
20030223221726
20030223221728
20030223221730
20030223221731
20030223221733
20030223221735
20030223221737
20030223221739
20030223221741
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
22233344455566677778889999
Some leading white space on this line.
Some trailing white space on this line.
Some extra new lines before this line.
a8 b8 c8 d8 e8 f8 g8 h8
a7 b7 c7 d7 e7 f7 g7 h7
a6 b6 c6 d6 e6 f6 g6 h6
a5 b5 c5 d5 e5 f5 g5 h5
a4 b4 c4 d4 e4 f4 g4 h4
a3 b3 c3 d3 e3 f3 g3 h3
a2 b2 c2 d2 e2 f2 g2 h2
a1 b1 c1 d1 e1 f1 g1

Double Spaced

All continuous occurences of new lines are replaced with two new lines.

ClipUtil Test Text

200302232134

20030223221717

20030223221718

20030223221720

20030223221722

20030223221724

20030223221726

20030223221728

20030223221730

20030223221731

20030223221733

20030223221735

20030223221737

20030223221739

20030223221741

ABCDEFGHIJKLMNOPQRSTUVWXYZ

abcdefghijklmnopqrstuvwxyz

22233344455566677778889999

Some leading white space on this line.

Some trailing white space on this line.

Some extra new lines before this line.

a8 b8 c8 d8 e8 f8 g8 h8

a7 b7 c7 d7 e7 f7 g7 h7

a6 b6 c6 d6 e6 f6 g6 h6

a5 b5 c5 d5 e5 f5 g5 h5

a4 b4 c4 d4 e4 f4 g4 h4

a3 b3 c3 d3 e3 f3 g3 h3

a2 b2 c2 d2 e2 f2 g2 h2

a1 b1 c1 d1 e1 f1 g1

Source Code

All trailing white spaces are removed.

ClipUtil Test Text
200302232134
20030223221717
20030223221718
20030223221720
20030223221722
20030223221724
20030223221726
20030223221728
20030223221730
20030223221731
20030223221733
20030223221735
20030223221737
20030223221739
20030223221741
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
22233344455566677778889999
Some leading white space on this line.
Some trailing white space on this line.

Some extra new lines before this line.

a8 b8 c8 d8 e8 f8 g8 h8
a7 b7 c7 d7 e7 f7 g7 h7
a6 b6 c6 d6 e6 f6 g6 h6
a5 b5 c5 d5 e5 f5 g5 h5
a4 b4 c4 d4 e4 f4 g4 h4
a3 b3 c3 d3 e3 f3 g3 h3
a2 b2 c2 d2 e2 f2 g2 h2
a1 b1 c1 d1 e1 f1 g1 h