1

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?

2
  • Where is the new folder to be located?
    – martineau
    Nov 4, 2011 at 14:45
  • Hi Martin, I think the new folder should be created in the same folder/desktop that I am browsering. Nov 4, 2011 at 15:21

1 Answer 1

5

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
    Return
3
  • Thanks, Ampersand, it really works! Though there seem to be a little problem creating new folder just on the Desktop Nov 7, 2011 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, 2011 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, 2012 at 18:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .