#If (WinActive("ahk_class Progman") || WinActive("ahk_class WorkerW") || WinActive("ahk_class CabinetWClass")) ; desktop or explorer F1:: WinGet, active_id, ID, A InputBox, name, Create a New Text Document, Enter a name:,, 300, 120 If !ErrorLevel { WinActivate, ahk_id %active_id% If WinActive("ahk_class Progman") or WinActive("ahk_class WorkerW") ; desktop { FileAppend,, %A_Desktop%\%name%.txt Run, %A_Desktop%\%name%.txt } else if WinActive("ahk_class CabinetWClass") ; explorer { WinGetTitle, ActiveTitle, A If InStr(ActiveTitle, "\") ; If the full path is displayed in the title bar (Folder Options) Folderlpath := ActiveTitle else If InStr(ActiveTitle, ":") ; If the title displayed is something like "DriveName (C:)" { Folderlpath := SubStr(ActiveTitle, -2) Folderlpath := SubStr(Folderlpath, 1, -1) } else ; If the full path is NOT displayed in the title bar ; https://autohotkey.com/boards/viewtopic.php?p=28751#p28751 for window in ComObjCreate("Shell.Application").Windows { try Folderlpath := window.Document.Folder.Self.Path SplitPath, Folderlpath, title If (title = ActiveTitle) break } FileAppend,, %Folderlpath%\%name%.txt Run, %Folderlpath%\%name%.txt } } return #If