Skip to content

Instantly share code, notes, and snippets.

@simshaun
Last active August 16, 2019 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simshaun/565fb79e1a42c6ebf644070c43ad8a7d to your computer and use it in GitHub Desktop.
Save simshaun/565fb79e1a42c6ebf644070c43ad8a7d to your computer and use it in GitHub Desktop.
AutoHotKey script that makes Ctrl+Shift+T create a new file while in Windows Explorer
; Ctrl + Shift + T //// When Windows Explorer active, create new file
#IfWinActive, ahk_exe Explorer.EXE ahk_class CabinetWClass
^+t::
WinGetTitle, currentWinTitle, A
if InStr(currentWinTitle, "\") ; If the full path is displayed in the title bar (Folder Options)
currentPath := currentWinTitle
else if InStr(currentWinTitle, ":") ; If the title displayed is something like "DriveName (C:)"
{
currentPath := SubStr(currentWinTitle, -2)
currentPath := SubStr(currentPath, 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 currentPath := window.Document.Folder.Self.Path
SplitPath, currentPath, title
if (title = currentWinTitle)
break
}
if (currentPath != "") {
InputBox, filename, Create new file, Filename?
if (filename != "") {
FileAppend,, %currentPath%\%filename%
}
}
return
#IfWinActive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment