Wednesday, December 19, 2007

Use AutoCorrect to type really fast

Like most people, I also use Microsoft Word to write documentation, email, etc. and one of the features I use the most is AutoCorrect. Warning: Once you start using it, it can be hard to live without it.

AutoCorrect is simply a list of characters that will get replaced with other characters. It is the automatic "replace as you type" function, and it is commonly used to fix typical misspellings and create emoticons such as a smiley. For example, if you type in "your here" in Microsoft Word, it
will automatically get expanded to a "you're here". To see the complete list, go to Tools->AutoCorrect Options in Microsoft Word. Note that AutoCorrect is language sensitive, so you have a different list for each language you compose messages in. This of course makes sense since you do not want to autocorrect abotu to about for Danish, but only for English.

But instead of using it to correct misspelled words, I use it to write longer words that I use over and over again. Below is a small sample of my own personal list.

Commonly used words and sentences:
sw=software
dev=develop
devn=development
anyq=Any questions, please do not hesitate to contact me.

You can also use AutoCorrect to write the correct capitalization of a given word or sentence. If you enter a word in lowercase in autocorrect, then Microsoft Word will automatically expand to the correct case. E.g. if you have a lowercase entry of sw for software, then sw will expand to software, and SW (in uppercase) will expand SOFTWARE, and Software if in the beginning of a sentence. Works pretty well. But if you always want to have SOFTWARE in uppercase since it may be a trademark name, etc, then all you have to enter is sw for SOFTWARE.

There are some words that you may want to autocorrect some of the times, but not all the times. The easiest way to handle this is to press undo (ALT-BACKSPACE or CTRL-Z) immediately after the expanding. So if you need to enter the address "123 SW MAIN ST", you want to press undo right after SW otherwise you'll send the letter to "123 SOFTWARE MAIN ST".

Lastly, note that you could also have an entry of uppercase SW. However, this means that SW is only expanded if you enter the uppercase SW. If you entered sw it would not get expanded.

I suggest you play around with it yourself. It is kind of like reading a book on riding a bicycle. It may get you an idea, but you'll not get the feel for it, until you jump on the bike yourself.

By the way, this entry was writing using 8 different AutoCorrect entries.

Nifty.

Tuesday, December 18, 2007

There are stars and then there are stars

Microsoft Word and Microsoft Excel are both fantastic programs that most of us use everyday. Personally I vote for Microsoft Excel as the best and most useful program ever written, but that is a completely different story. But it is funny to see how differently the two programs function despite both being developed by the very same company (but clearly by different departments).

Take searching in Word versus Excel. In Word you can replace an asterisk (*) with a B by simply using Find=* and Replace=B. So A*C becomes ABC.
It (kinda) makes sense, but in Excel the asterisk (*) is suddenly used as a wildcard character that you can not easily turn off. So A*C now becomes B as the whole cell is matched. God forbid someone as Microsoft should discover standard regular expressions.

But how do you then replace an plain asterisk (*) inside text in your Excel file. Well, it turns out that you put a tilde (~) in front of the asterisk. Yeah, don't ask me how tilde suddenly became the escape character instead of backslash. So when you use Find=~* and Replace=B, then
A*C correctly becomes ABC. Again, God forbid someone as Microsoft should discover regular expressions and using \ as the escape character.

Microsoft, in case you are listening, please add an option to use real UNIX style regular expressions. I mean it is a standard after all. But at least we have a way to replace asterisks in Excel.

Nifty.

Saturday, December 15, 2007

DOS Prompt FOR command

The FOR command available in the DOS prompt is surprisingly useful. As you may have seen in the earlier blog the help on the FOR command (i.e. "HELP FOR") has a lot of useful information. I personally find that I use the FOR /L option more than any of the others. For example, if you need to create 100 directories named NewDir0 to NewDir99 you clearly do not want to do that from the Windows Explorer (AKA Windows Exploder). And you do not want to start typing mkdir manually from the command prompt either.

Instead, use the FOR command. But before you start creating a hundred directories, you should always use the echo command to test your FOR loop.

The FOR /L allows you to specify the start, step, and end of the loop, so the command:
C:\>FOR /L %i in (0,1,99) do @echo NewDir%i

Will echo:
NewDir0
NewDir1
...
NewDir99

Once it works the way you want it to, simply replace echo with your desired command (e.g. mkdir) and you whoopty you got yourself 100 directories.

Nifty

DOS prompt file information

Ever need to get the size of a file or get the short DOS 8.3 name from the command line or from a BAT script. Simply type in "HELP FOR" in the DOS prompt to get help on the FOR command. In here you'll also find the nifty tags to get that special information about files passed as arguments. For example, %~s1 will get the short DOS 8.3 name of the first argument, %~z1 will get the file size, %~p1 will get the path, etc.

You may for example create a small BAT file (e.g. named dos83.bat) that contains the following line. When called it will show the short DOS8.3 name of the argument passed in.
@echo %~s1

Output Example:
U:\My Documents\My Templates>dos83 .
U:\MYDOCU~1\MYTEMP~1

Nifty

DOS prompt command history

When working in a DOS prompt you often need to repeat commands, or at least execute very similar commands. There are a few nifty ways to repeat commands in a DOS prompt.

F3: Copy last command to command line.
F7: Shows your entire command history. Press enter to select a command and execute it. Press -> or <- (right or left arrow key) to copy the command to the prompt, so you can modify it.
F8: Command completion (like filename completion). Enter the first few letters of any previous command, press F8 to rotate through all previous commands starting with these letters.

Nifty

DOS prompt navigation (file name completion)

So now that you have the DOS prompt (see earlier blog entry), you need to make your DOS prompt navigation as painless as possible, so make sure that you have file name completion turned on. It is very easy to turn on (if not already on). It is a small registry tweak. Simply paste the following into a file with extension .reg and execute it.

Press TAB and SHIFT-TAB in any DOS prompt to get the file and directory names auto-filled in. You can even type the starting letters to limit to matches found. E.g. in C:\ type in P and press TAB and you'll see all the files and directories starting with P, e.g. "Program Files".

Nifty.

REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor]
"CompletionChar" = dword:00000009

DOS prompt in any folder

Ever need to quickly get a DOS prompt in a certain folder? It is not easy to do in a standard windows configuration. I often need to get a DOS prompt to run various tools (e.g. Perl tools), and it frustrated me that I have to open a command prompt (i.e. cmd) and then navigate to the folder.

So here is the solution. It is a small registry tweak that allows you to right-click on any folder and get a prompt. Simply paste the following into a file with extension .reg and execute it. In an Explorer window you can also right-click on the folder icon in the very top left corner to get a DOS prompt.

Nifty.

REGEDIT4
[HKEY_CLASSES_ROOT\Folder\shell\Prompt\command]
""="cmd.exe /n \"%1\""

Wednesday, December 12, 2007

Capture screenshot of drop down menu

Once in a blue moon you need to capture a screenshot (aka screendump) and paste it into a document or a web page. As you probably know this is quite easy using the PrintScreen (aka PrntScrn) key which will capture the screenshot and put it on your clipboard. Typically there are two ways to do this.

PrintScreen: Screenshot of the entire screen (i.e. all windows)
ALT + PrintScreen: Screenshot of only current window (i.e. window in focus).

However, what if you need to capture a screenshot of the current window with a drop down menu showing? That is a bit more difficult as the drop down menu disappears as soon as you press the ALT key. So there are 2 ways to do this:

You could grab the entire screen using PrintScreen and bring the capture into Paint (or any other paint program) and cut out the part that you need.

However, there is a much simpler solution. Put focus on the window you want to capture. Close the drop down menu if open. Press ALT + (letter to open the drop down), keep holding ALT down, and press PrintScreen. You can even move the mouse around to highlight the item you want as long as you keep holding down ALT.

For the screen shot below, I pressed ALT + v (to open View), then I moved the mouse to open "Text Size", then I pressed ALT + PrintScreen to capture the window plus drop down. The important thing is to hold down the ALT key the whole time.





2017 update:  You can also use the new Windows built-in capture tool called Snipping Tool. Press Windows key (lower left, typically next to ALT button), and type "snip" and you should see it pop up in your menu. Press ENTER to run. Now drag to capture. Automatically copied to clip-board.  To capture menus, open Snipping Tool, and press ESC to temporarily disable to capture. Now open menus to capture, and press CTRL-PrintScreen to open Snipping Tool.

Happy screen capturing.

Welcome !!

Welcome to the first posting on the "Nifty PC tricks" blog. Here I'll post solutions to and discussions about some of the many PC issues or peculiarities that I run into during my busy life. And I just want to thank Microsoft for keeping the list long. Personally I fall in the category of advanced PC users, somewhere between expert IT dude and novice surfer, so the solution and discussions will be targeted to the advanced PC users too.

Anyway, enough talk. Let's talk nifty tricks.