Sunday, May 24, 2009

Remapping keys for closing windows

Requires: Windows 2000/XP, AutoIt3, and PS Hot Launch.

Really simple tweak today. In Windows, the shortcut to close a window is "Alt-f4." That annoys me. I mean, it takes two hands, the keys are far apart, blah blah blah... Really, this is one of those things that I probably should have just gotten used to, but... I didn't. Instead, I found a way to use "ctrl-down", which works well for me since I'm using "ctrl-(other arrow keys)" for navigating windows explorer. I find it easier and faster to use the right ctrl with the arrow keys for quick navigation. My solution uses an Auto It script and PS Hot Launch.

The AutoIt script is really simple:

      WinClose( "" )

It'll close the program that currently has focus. Simply save that code and map it (using PS Hot Launch) to "ctrl-down." You can use PS Hot Launch to to make up a lot of your own commands and tweak all your keyboard shortcuts without actually changing the keys. The only thing to be careful about is not ruining pre-existing shortcuts.

As I was writing this, I realized the title could be misread to mean closing the Windows Operating System. In case that mistake lead you to read this, I'll give you a tip to close that from Command Line. Simply type in:

      shutdown -s -f -t 0

This'll shut down the computer, not give you program warnings, and do it without a delay. Do "shutdown -?" for more options. Cinchy. You can put the code in a batch file and then map it to a key or put it on your desktop and click on it when you want to shutdown. I think it's a better method than the click through GUI.