Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I make F1 be a hotkey in Windows XP assigned to creating a new folder?

I don't know too much about programming or scripting. Can AutoHotkey do this?

share|improve this question
Where is the new folder to be located? – martineau Nov 4 '11 at 14:45
Hi Martin, I think the new folder should be created in the same folder/desktop that I am browsering. – grandproducts Nov 4 '11 at 15:21
up vote 5 down vote accepted

Yup. Use FileCreateDir.

windowText =
line =
path =
name =

$F1::                                                   ;the $ locks the keystroke so you don't get Windows Help
    IfWinNotActive, ahk_class CabinetWClass
        Return                                          ;If the active window is not an explorer window, do nothing
    WinGetText, windowText, ahk_class CabinetWClass,    ;get text info
    StringSplit, line, windowText, `n                   ;take the first line of windowText this will be "Address: path"
    StringReplace, path, line1, Address: `              ;trim off Address: 
    StringTrimRight, path, path, 1                      ;trim off new line character at the end
    InputBox, name, MakeDirF1, Enter the name of the new folder.    ;get a name
    If name == ""                                       ;if name is blank
        name := "New Folder"                            ;then set name
    FileCreateDir, %path%\%name%                        ;create the folder
    If ErrorLevel == 1                                  ;check for errors
        MsgBox, Error!`n`n%A_LastError%                 ;message box if error
share|improve this answer
Thanks, Ampersand, I'll check it out! – grandproducts Nov 7 '11 at 12:26
Thanks, Ampersand, it really works! Though there seem to be a little problem creating new folder just on the Desktop – grandproducts Nov 7 '11 at 12:38
Hmm... sorry for the late reply. It would work if you navigated to the desktop in an Explorer window. Otherwise, you can just map a key to send the requisite keystrokes. $F1:: { Click, Right Send, wf RETURN } – Ampersand Nov 18 '11 at 17:40
@Ampersand: Seems like you could detect when the desktop is active by looking for an active window of ahk_class Progman and then automatically create a subfolder in the user's desktop folder if that's the case. Also, at least on my XP SP3 system, Explorer windows have a ahk_class ExploreWClass, not CabinetWClass. – martineau Mar 4 '12 at 18:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.