I haven't seen any shortcut for creating "A New Text Document" or any file. Is there any?
10 Answers
Windows 7 and earlier: Alt+F, W, T works, regardless of whether the file or folder pane has focus.
Windows 8: This doesn't work in any more. Menu, w, t works as long as the file pane has focus.
Windows 10: Menu, w, t works as long as the file pane has focus and no file is selected. Press CONTROL-SPACE to clear the selected files (thanks @RogUE).
Windows 10 2nd Method: Alt+H, W, UP, UP, UP, ENTER. This works in even if a file is selected:
-
1This is the only built-in-solution I found for Win7. Still wonder why Microsoft has decided to use shortcut
w
for New
. Why notn
to make it easy?– AvatarJan 5, 2014 at 21:43 -
1@EchtEinfachTV: Look at the underlined letters in the menu. “New” can’t be ‘N’ because ‘N’ is “Se
n
d to”. (And “Send to” can’t be ‘S’ because ‘S’ is “Creates
hortcut”. And “Create shortcut” can’t be ‘C’ because ‘C’ is “C
lose”.) ... (No relation to Ben.) Jul 9, 2014 at 19:46 -
1If a file or folder is selected, you could hit crtl+space to deselect it– RogUEMay 6, 2016 at 1:43
-
1@RogUE it works for only a certain file. When I enter a folder, select some files then do ctrl+space it only selects or deselects a certain file, not all the selected files, on Windows 10 that is. Jul 28, 2016 at 9:04
-
thanks for Control + Spacebar combination to clear the selected files. I used Alt+Up to go up, then Enter to return the folder, so silly :).– Doan VuMay 18 at 7:32
I wrote a script based on the suggestions to use AutoHotkey. If you want to change the .txt
file extension, this requires Hide extentions for known file types
to be off.
#IfWinActive, ahk_class CabinetWClass
#n:: ;If Windows+N is pressed in Windows Explorer
Send {Alt} ;Menu
Send f ;> File
Send w ;> New
Send t ;select Text Document
Send ^a ;select all
Exit
If you need any help with AutoHotkey, let me know. :)
-
Where does the limitation on the visible file name extensions come in?– Daniel Beck ♦Jan 26, 2012 at 19:44
-
@DanielBeck Studiohack merged two questions. The one that I originally answered asked if the file extension could be removed. Since we are using
.txt
, we should select the whole file name including.txt
. I've updated my answer to clarify.– iglvzxJan 26, 2012 at 19:46 -
Thanks iglvzx! I added
Send {Delete}
because even though everything was selected, typing only deleted the part before the extension.– VorikiJan 27, 2012 at 14:29 -
1
-
1If you want to rename the file to what you have in the clipboard and open the file afterwards use this:
SendInput !fwt Sleep 100 SendInput ^a{backspace}^v{enter}{enter}{enter}
– phroggJan 8, 2019 at 16:13
The following works under XP (I don't have Windows 7):
- make sure the Files (not Folders) pane has focus (Tab or F6 to get there).
- make sure no file is selected (press CTRL+Space to unselect one file if necessary).
- bring up either the File menu with Alt+F or the context menu with the context menu key or Shift+F10.
- Press W for New, and T for Text Document.
-
1This is a looong procedure. Something like Ctrl+Shift+T will do. Apr 21, 2010 at 12:07
-
It works, but not if any other applications start adding to the file menu to interfere with the W shortcut e.g. WinMerge. Oct 8, 2013 at 13:54
-
This still works under Windows 8. When other application add menu items with the W shortcut, you have to press the W key twice and submit with enter or right arrow key.– danijarJun 21, 2014 at 14:11
-
Alt+F, W, T works well and I've used it a long time in Windows XP, Vista and 7, no good in Win10. Feb 14, 2020 at 16:31
-
Wow! [Shift]+[F10], [W] for New, and [T] for Text Document works on Windows 10. :-)– HenkeMay 27, 2022 at 15:05
It may be possible with a third party solution (haven't tested it, autokey is famous too), since it's not available in Windows 7's official keyboard shortcuts. You can create a new folder using Ctrl+Shift+N
though.
I just tried the following on my Swedish Windows 7 machine and it works good. No need to install third party.
- Open folder
- Press ALT-key to display menubar
- A (Swe. Arkiv, Eng. File)
- N (Swe. Nytt, Eng. New)
- T (Swe. Textdokument, Eng. Textdocument)
Short: ALT, A, N, T
Right click (leave right click mouse button) then press 'W' (leave W) and finally press 'T' works with windows 8.1
I've been using this autohotkey script for ages.
; New text file
#IfWinActive AHK_CLASS #32770
Capslock & f11::
#IfWinActive AHK_CLASS CabinetWClass
Capslock & f11::
; make it work even though a file is previously selected
Send {PgUp} ; Force select the first file
Send ^{Space} ; Clear the selection
Sleep 250 ; Remove delay if not required
Send {AppsKey} ; Menu key
Send w ; New
Send t ; Text Document
return
#IfWinActive
- Works on file dialogs (save as / open file)
- Works even though a file is selected
- Works even though cursor is positioned off screen
Change "Capslock & f11" to your preferred shortcut.
To understand the syntax above, see below example,
; Syntax - To have the same hotkey subroutine executed by more than one variant, the easiest way is to create a stack of identical hotkeys, each with a different #IfWin directive above it. For example:
;#IfWinActive ahk_class Notepad
;#z::
;#IfWinActive ahk_class WordPadClass
;#z::
;MsgBox You pressed Win+Z in either Notepad or WordPad.
;return
Hope you find this useful!
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#NoTrayIcon ; the process will not appear on windows taskbar on the right
#IfWinActive, ahk_class CabinetWClass
^r:: ;
KeyWait Control
Sleep 40
Send {Alt} ;
Sleep 40
Send {Enter};
Sleep 40
Send {Enter}
You need to create .ahk file with this script. Also, you need to check if it creates .txt file. For this, open windows explorer, press Alt, then press enter, and look how many times do you have to press Up arrow key to it to open .txt file. After that, copy or delete those two lines of code
Send {Enter};
Sleep 40
Don't forget to add this to your startup apps folder so that you don't have to open this script every time. You can do that:
- open the windows run app by pressing win+r
- type: shell:startup
- drag your .ahk script to this folder
Method 1 [FileAppend & GetActiveExplorerPath()]
@logic::
FileAppend , Text, Filename, Encoding
Writes text to the end of a file (first creating the file, if necessary).
GetActiveExplorerPath()
&GetExplorerPath(hwnd=0)
@reference::
- for details see Create a text file with a keyboard shortcut in Windows Explorer
@source_code:: (basically same as the code in reference above)
; ######################################################
; ~~// https://superuser.com/questions/1091268/how-to-create-a-new-text-document-txt-file-by-a-hotkey
; ~~// https://superuser.com/questions/133175/is-there-a-shortcut-for-creating-a-new-file
; https://superuser.com/questions/1368969/create-a-text-file-with-a-keyboard-shortcut-in-windows-explorer
#If WinActive("ahk_class CabinetWClass") || WinActive("ahk_class ExploreWClass") || WinActive("ahk_class Progman") || WinActive("ahk_class WorkerW")
#n::
WinGet, active_id, ID, A
name := "NewTxtFile"
; WinActivate, ahk_id %active_id%
if (WinActive("ahk_class CabinetWClass") || WinActive("ahk_class ExploreWClass")) { ; explorer
FolderPath := getWindowsExplorerPath()
FileAppend,, %FolderPath%\%name%.txt
; Run, %FolderPath%\%name%.txt
}
else if (WinActive("ahk_class Progman") || WinActive("ahk_class WorkerW")) { ; desktop
FileAppend,, %A_Desktop%\%name%.txt
; Run, %A_Desktop%\%name%.txt
}
return
; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=69925
getWindowsExplorerPath() {
explorerHwnd := WinActive("ahk_class CabinetWClass")
if (explorerHwnd) {
; i := 1
for window in ComObjCreate("Shell.Application").Windows {
; ToolTip(++i)
try {
if (window.hwnd == explorerHwnd) {
return window.Document.Folder.Self.Path
}
}
}
}
}
#If
@minor-comment::
this method may be recommended over the others, since
window navigation panel
&popup context menu
are unreliable due to their: slowness (depends) / wait for popup / diff windows version hotkey are different / if your popup context menu has the hotkey conflict with others(aga) this method may (or may not) be slower than others
FileAppend
does what it means -- so if you already have one file with the nameNewTxtFile.txt
, it appends to that file ...tweak the code if you need
this doesnt focus to the file for editing the file name
Method 2 [window navigation panel]
(another answer above) https://superuser.com/a/194593/997622
Method 3 [popup context menu]
(as many other answers talked) SendInput, {AppsKey}wt
Get AutoHotkey.
Then you need create or find a script for shortcut binding. For more, read the AHK tutorial.
-
3So, how does this exactly solve the problem? Which script should they use?– slhckJan 26, 2012 at 18:37
-
1