In Explorer if you hit F2 to rename a file Vista automatically selects the file name WITHOUT the extension, something that does not happen in XP.

It’s very possible that there are better ways to add this functionality, but it’s wildly easy to do with AutoHotkey. Every time you hit F2 to rename a file, you also need to hit Shift+Left Arrow four times. Using AutoHotkey, the process is automated.

If you’re just interested in getting the functionality, either download the Better Rename.exe file or download the AutoHotkey source.

If you want a better idea of how it works, check out the code below:

======================= CODE ===========================

#IfWinActive ahk_class CabinetWClass
~F2::
Gosub, AnalyzeRename
return

#IfWinActive ahk_class Progman
~F2::
Gosub, AnalyzeRename
return

#IfWinActive

AnalyzeRename:
OldClipboard = %Clipboard%
sleep 100
Send, ^c
StringGetPos,ExtensionPos, Clipboard,.,R

if (ExtensionPos != -1)
{
Position := StrLen(Clipboard) – ExtensionPos
Send, +{Left %Position%}
}

Clipboard = %OldClipboard%
return

========================================================

Source Code Explaination

The IfWinActive command tells AutoHotkey only to use these F2 definitions if your active Window or application is Windows Explorer or your Desktop. If either of those conditions are met, F2 is sent to the window, and then AutoHotkey automates the Shift+Left keystrokes necessary to un-highlight the extension, but it does so quickly enough that it’s really as though that’s just the way renaming works.

This was a very quickly thrown together script, and there are limitations that could be improved. I did add checking for the first period from the right so that F2 can handle extensions of differing lengths and so that it doesn’t try adjusting the selection for items that don’t use extensions—folders, for example.

It’s not absolutely perfect, but it should do the trick most of the time if you’ve been aching from the renaming functionality that’s available in both Vista and OS X.

Credits To LifeHacker

Source : LifeHacker

Interested in more of what AutoHotkey can do?

Check out this introduction or any of many AutoHotkey posts. [LifeHacker]

Advertisements