Sunday, February 24, 2008

Utility of the day: ClipPath

ClipPath is a shell extension for Windows which adds an option to the right-click menu for files and folders to copy the location (fullly specified path and filename) of the file to the clipboard. It's a handy timesaver in lots of situations.

For example, after saving a file such as a Word document to some deeply-nester folder, you might want to attach that file to an email message. Normally, to do this, in your email program, after activating the "attach file" function, you'd then have to browse through the filesystem to the location to which you'd just saved the file.

With ClipPath, after saving the document, you can just bring up an Explorer window with the location of the saved file (by doing a File | Save As from the application where you were editing the document), right-click the saved file, and copy the file's location to the clipboard with the ClipPath option on the right-click menu. Then, cancel out of the Save As dialog, and in your email program, activate the "attach file" function, and just paste the full path to the file in the Open File dialog (instead of having to manually browse through the filesystem to the file's location).

I've been using ClipPath for well over a year now, and I've never had a problem with it. You can download ClipPath from the Essential Developer Resources page of the website of the utility's author, sureshms.

Friday, February 22, 2008

Java: Getting a String with the current call stack

Occasionally, in debugging, it can be useful to get the current call stack trace of a program as a String. Here's a simple Java method that will do this:
private static String getCallStackString()
{
 java.io.ByteArrayOutputStream byteArrayOutputStream = new java.io.ByteArrayOutputStream();
 java.io.PrintStream printStream = new java.io.PrintStream(byteArrayOutputStream);
 Throwable throwable = new Throwable("Current call stack:");
 throwable.printStackTrace(printStream);
 return byteArrayOutputStream.toString();
}
Note that this works even in pre-1.4 Java versions, since it doesn't use the getStackTrace method (introduced in Java 1.4). The output of this method is a string along the lines of the following:
java.lang.Throwable: Current call stack:
 at JavaTest.getCallStack(JavaTest.java:36)
 at JavaTest.main(JavaTest.java:24)
A minor variant of this method can be used to get the call stack of an existing Exception:
private static String getCallStackString(Throwable throwable)
{
 java.io.ByteArrayOutputStream byteArrayOutputStream = new java.io.ByteArrayOutputStream();
 java.io.PrintStream printStream = new java.io.PrintStream(byteArrayOutputStream);
 throwable.printStackTrace(printStream);
 return byteArrayOutputStream.toString();
}

Wednesday, February 13, 2008

Utility of the day: Taskbar Shuffle

A user interface convention that is emerging as a standard for applications that support having multiple pages or documents open in tabs, such as web browsers (including Firefox, Internet Explorer 7, and Opera 9) and IDEs (including Visual Studio and, in an upcoming version, Eclipse), is the ability to click a tab with the middle mouse button to close the tab. This is useful for several reasons: (1) It's easier to position the mouse cursor over a tab than on a small button on the tab; (2) it prevents accidental closing of a tab with the left mouse button (when the close button on the tab is left-clicked inadvertently instead of on the remainder of the tab area); and (3) optionally, it allows the close button each tab to be removed (resulting in more available space on the tab for displaying the name of the tab's document).

I always thought it would be nice to be able to apply this same UI convention to Windows Taskbar buttons. After all, what is the Windows Taskbar but a tabbed view of all open applications? The ability to middle-click a Taskbar button to close it would be much nicer than having to right-click an application's Taskbar button and choose "Close" from the context menu that appears. (Trying to close many applications in quick succession in this way can be particularly aggravating when closing an application that doesn't follow the common convention of having the "Close" option as the bottom option in the context menu, such as cmd.exe command prompt windows – you end up having to hunt for the "Close" option among the other options, instead of just clicking the "Close" option immediately.)

I recently came across a free utility that allows a middle-click on a Taskbar button to close the application: Taskbar Shuffle by Jay E. The primary purpose of Taskbar Shuffle is, as its name implies, to allow Taskbar buttons to be reordered via a simple drag-drop. However, Taskbar Shuffle does also implement the middle-click-to-close functionality. Very cool!

I was initially a bit leery of installing a utility that hooks directly into Windows' explorer.exe (as I presume that Taskbar Shuffle must do in order to provide the functionality that it does), for fear that the utility could potentially bring down Explorer itself if something were to go wrong. However, I searched around for comments on the application, and found many very positive comments (including on the app's own forum) about the app, and no negative comments, so I took the plunge and installed it. I'm glad I did; on my machine (running 32-bit Windows XP Pro), Taskbar Shuffle is rock-solid stable! I've found it to be one of those extension-type applications that is just so useful, you wonder why its functionality isn't built into the base product itself (in this case, Windows).

One caveat: Apparently the current version (v2.2 as of this writing) doesn't support 64-bit versions of Windows yet. A 64-bit version might be on the way, though; the application appears to be actively developed, and some text near the download link notes "hold tight for 64-bit".

Update 7/1/2009: A 64-bit version is now available! Go check it out.

Go get Taskbar Shuffle from Jay E.'s website, here.

Thursday, February 07, 2008

Utility of the day: closeall.exe

Closeall.exe is a great, simple little utility program for Windows that does just one thing: When run, it sends a "close" signal to each running application, as though you had clicked the application's own Close button. (Thus, each application is closed in a "friendly" manner, having a chance to prompt you if the app has an open document with pending changes that need to be saved, and so forth.)

I've been using this utility daily, running it as a first step in shutting down my computer. At the end of a typical work day, I often have many applications open, and using closeall.exe to close them all in a controlled fashion has turned out to be a very nice alternative to either the hassle of manually closing each application one-by-one prior to shutdown, or else telling Windows to shut down with all of my applications still open, and then dealing with the subsequent chaos of Windows trying to shut down all of my applications at the same time that it is also stopping background processes and performing other shutdown tasks.

Closeall.exe was written using pure Win32 API by Alexander Avdonin. You can download it from its page at Alexander's ntwind software site, here.

Friday, February 01, 2008

Workaround: Mouse Sensitivity Settings Lost after Laptop Re-dock

Issue: After undocking and then re-docking my Thinkpad T60 laptop (running Windows XP), my custom sensitivity settings for my external Logitech mouse (an MX500) are lost; in particular, the mouse cursor acceleration effect is gone, and the base speed of the movement of the mouse cursor increases significantly.

(Since I run dual high-resolution monitors, I find it very useful and comfortable to set the base mouse cursor speed to a low setting to allow easy precision pointing, and to also enable fairly high acceleration to allow me to move the mouse cursor long distances on my large screen area without having to move the physical mouse a correspondingly long distance on my desk. Moving the mouse on my machine and expecting to have the cursor respond according to these settings, but instead getting high-speed, no-acceleration cursor movement, feels very jarring.)

Also, after re-docking, the custom Logitech-provided mouse controls (the "Logitech MouseWare Control Center") in the Mouse applet in the Windows XP Control Panel are gone. Instead, running the Mouse applet just brings up the basic Windows mouse applet.

Workaround: Running the program logi_mwx.exe (which I found located on my local machine at C:\Windows, and, per msconfig.exe, runs at system startup time) restores the custom Logitech mouse control panel applet and my custom mouse speed and acceleration settings.

Of course, rebooting the machine is also an effective workaround! (The drawback to rebooting, of course, being the necessity of waiting for the reboot, and then re-opening any applications and documents that were in use prior to the reboot.)

As an aside, the same symptoms occur whenever the Microsoft Virtual PC 2007 Console is the active (foreground) application on my machine, even when no virtual PC image is actually running. If anyone knows a better workaround for this issue than "keep Virtual PC as the foreground app as little as possible", please comment! :-)