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?
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?
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
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
.
Mar 4, 2012 at 18:50