Friday, March 6, 2009

HOW TO Windows: Play with SAPI

Dim message, sapi
message=InputBox("What do you want me to say?","SAPI")
Set sapi=CreateObject("sapi.spvoice")
sapi.Speak message

SAPI is Windows' Text-to-Speech functionality. This Visual Basic script will present you with an input box that will read back to you whatever you type into it. (Ok, this isn't immediately as useful as it is fun. But it's great for pranks, and you can find the script extremely useful once you learn to tweak it with Visual Basic.)

1. Open a new notepad file. Copy the above script into this new text document.


2. Save the file with any filename ending in the extension ".vbs" (script.vbs or talk.vbs, for example).


3. Double-click on the resulting icon to run the script. After you've entered your text in the box and pressed the button, the box will disappear and SAPI will read back what you've typed. (There may be a bit of a delay depending on your processor, but this WILL work if you have a valid install of Windows XP, Vista or 7.)

Thursday, March 5, 2009

HOW TO Women: Convince a woman you're not cheating on her.

"I have no reason to cheat on you. There's nothing another woman could give me that you can't. You're absolutely everything I want."

Note that this won't work if she has an actual reason to not trust you - like, that you're ACTUALLY cheating on her. (And if you are, you're a douchebag and you deserve to get caught.) This will only work if she's being unreasonably paranoid and you want to shut her down. Don't try to argue with her or validate her specific points. Just look her dead in the eye and say it firmly, calmly and without blinking. If she doesn't calm down immediately, repeat - simply, logically, and matter-of-factly.

This line will accomplish everything - it's coldly logical, but it's also incredibly romantic. It compliments her deeply, while at the same time reminding her that she's an idiot for ever questioning you. You win.

Friday, February 20, 2009

HOW TO Windows: Add a "Delete Folder Contents" command to the right-click menu.

cmd /c "cd /d %1 && del /s /q *.*

(Note: this how-to requires you to edit your registry. You should ALWAYS back-up your registry before editing it. Don't complain at me if Windows stops working because you added or deleted the wrong key and can't fix it.)

1. Open the registry editor (type "regedit" in the Search box or the Start|Run box). Navigate to HKEY_CLASSES_ROOT\Directory\shell.

2. Right-click on shell and add a new key. Label it "Delete Folder Contents".


Now right-click on Delete Folder Contents and add a new key, labeling that key "Command".


3. Double-click on (Default) in the right-hand pane and type cmd /c "cd /d %1 && del /s /q *.* .


That's it. Now, when you right click on any folder, you'll see that "Delete Folder Contents" has been added to the context menu. Clicking on it will delete every file and folder in that directory.

Thursday, February 19, 2009

HOW TO Notepad: Auto-Timestamp a Text File.

.LOG

This is a useful little trick if you regularly use a simple notepad file to keep a list, like a "to-do" file, or a personal diary.

1. Open a new notepad file. Type .LOG, then enter one carriage return (hit the Enter or Return key).

2. Save, name and close the file.

3. Now reopen the file. You'll see that notepad has automatically inserted a time/date stamp.

Notepad will once again place a time/date stamp at the bottom of the text file every time the file is reopened, as long as .LOG remains at the head of the file. You can type any information you wish after the time/date stamp; after you save, close and reopen the file, a new time/date stamp will be inserted at the bottom of the page.

Wednesday, February 18, 2009

HOW TO HACK: Prevent an elevator from stopping at any floor except your destination.


The Close Door Button and Your Destination's Button

This is a trick left over from the days of swanky hotels when a bellhop would use it to prevent a V.I.P. from having to share an elevator with a commoner. By holding down your destination and the close door button at the same time, you'll prevent the elevator from stopping on any other floor. You'll find this trick works on most name brand elevators (including Otis and Dover) though it can be turned off by the building engineer. Still, you may find this trick extremely helpful at noon when you're trying to leave the building for lunch.

Tuesday, February 17, 2009

HOW TO Excel: Cut a list of variable length cells into two pieces.


=LEFT(x,LEN(x)-y) (see this post)

- and -

=RIGHT(x,LEN(x)-LEN(z)) OR =MID(x,FIND("w",x),99)

The first formula will produce the first half of the broken text string. x is the cell containing the full text to be broken. y is the number of characters in the text you want to be in the second column.

If you've applied this formula and not made any manual changes on any lines, then the first of the other two formulas should work perfectly. x is still the cell containing the full text to be broken. z is the cell in which you placed the previous formula. This formula essentially says "return a number of characters from the right equal to the first cell minus the second cell."

If you needed to make some manual changes to the previous formula because a few of the lines didn't come out exactly the way you wanted, then you may need to use the second formula. In this case, x means . . . exactly what it meant before. But w is the first character in the text where the break should occur. (Note that this obviously means that all text lines should contain a specific character where the break should occur, and that character should only occur once in each line; or at least it should be the first occurrence of the character in that line. Otherwise, you'll return errors.) This formula says "Find w in the first cell. Then, return that character and up to 98 more after it."

Example: let's return to our list of movies from the hard drive. As you'll see, the first formula has been entered into Column B, producing our list of movies without the extension. (To see how to do this, visit this post.)

Because this formula worked well for our tiny list, the first of the two latter formulas should work just fine. By applying it in the C column, we can see that the formula has correctly subtracted the text in Column B from Column A. (Note that I added "-1" to my version of the formula - I did this to remove the stray space that would have appeared before "(1984)", since we cut that space out of Column B.)

But what if this didn't work? What if you had problems with the first formula because (for example) the lengths of a few of your extensions were different, and you had to fix those few lines manually? In that, case, you could try using the second formula. It does work just fine here - I only use it as a second option because it's a little more complicated and it has the character requirement mentioned earlier. Here you can see I've applied this formula to Column D.

Perfect. Now if I copy and paste these formulas down through my list . . .

Column A has been successfully broken into B and C (or D).

Monday, February 16, 2009

HOW TO DOS: Make a list of files in a directory.


DIR >file.txt

file will be the name of the text file containing your list of files. And yes, the list of files will include this file, so you may want to delete it from the list if and when you begin editing it.

(Note: if you were not intimidated away by the word "DOS", you probably already know how to reach a DOS prompt in Windows. But in case you don't, click on the Start button (and then click "Run" if you're in Windows 98 or XP) and in the search box type CMD. When you're done using DOS, type exit to close the DOS window.)

1. Using drive prompts and the cd command, navigate to the directory where your files are located. (Again, if you're unfamiliar with DOS, here is a list of DOS commands. To change drives, type c:, where c is the drive letter where you want to navigate. To change directories, type cd directory, where directory is the name of the file folder. You may need to use this latter command multiple times to reach your target folder.)

2. Type the above code. You'll notice that nothing appears to happen; that's because the DIR command, which would normally produce a directory listing on the screen, is instead outputting to the text file you specified. (Incidentally, if you have a printer on LPT1, you can use DIR >PRN to send your directory listing to the printer.)


3. You can now open a text editor like Notepad, or an Office suite program like Word or Excel, to view, change and print the contents of this file.