31

OS: Windows (Windows Explorer).

I'm frequently using: RightClick → New → Text Document

It lets you to name the file before opening and saving it. Is there a solution to run a script by a Hotkey and get it? (No matter what the Keyboard Layout is)

Maybe this can help "Create new text document" option missing from context menu

5
  • Half of the answer might include: pin Notepad to the start menu via right click -- pin to start menu. After that, click on the new Notepad entry on top of the start menu and choose Properties. In the Shortcuttab, hit the mouse cursor into the Shortcut Key box and press your chosen hot key, e.g. ctrl-alt-n. Close the properties windows with "OK". After that, Notepad will be started after you press ctrl-alt-n. However, if you hit File - Save as... in Notepad, it will open your Documents library, so you have to browse to the final destination first.
    – stueja
    Jun 20, 2016 at 11:17
  • Thank you for your answer, but the question is about, how to name the txt file before you open it for editing - a Hotkey for this.
    – Stamimail
    Jun 23, 2016 at 8:04
  • You should clearly state what OS (OS family) and file manager you are talking about. I can guess it's Windows and its native explorer.exe and I'm probably right; nevertheless your question should provide that information. A tag will be useful. Jul 3, 2016 at 17:33
  • Another hint: fsutil file createnew emptyfile.txt 0
    – Stamimail
    Jun 22, 2018 at 8:38
  • 1
    Although not a hotkey. I find it much faster to do Ctrl + L and touch file.txt
    – user1274669
    Mar 16, 2022 at 18:40

8 Answers 8

31

You can actually use your keyboard to naviagte the right-click menu.

Just right click and press W then T.


If you want to customise a keyboard shortcut, you could use something like AutoHotKey. An example script to do what you want would be like this.

F4::
Macro1:
Click, Right, 1
Sleep, 10
SendRaw, wt
Return

You can use this script by copying it to a text file and saving it as .ahk. With AutoHotKey installed, just double-click to activate.

Quick note:

The first line tells it to run the actions when the F4 is pressed. You can change the key by editing the first line.
The modifier keys are as follows:

# Win (Windows logo key)
! Alt
^ Control
+ Shift
& An ampersand may be used between any two keys or mouse buttons to combine them into a custom hotkey.

Where ^C means Control + C
Anything more advanced can be found in the docs. I suggest checking out the tutorial page.

5
  • Assuming Windows and Windows Explorer.
    – ak11234
    Jul 4, 2016 at 21:56
  • 1
    This solution is a kind of workaround. I was looking for a more direct solution, but thanks.
    – Stamimail
    Jul 7, 2016 at 13:10
  • instead of doing a mouse click, it's better to press the menu key on the keyboard which is called AppsKey in AHK
    – phuclv
    Sep 12, 2018 at 5:04
  • 2
    The menu key should be used. The OP was asking for a "hotkey" not a mouse click.
    – Avatar
    Jan 7, 2019 at 5:55
  • 3
    Well, yesterday I was about to create a New Folder using ctrl + shift + n. Then I accidentally pressed some wrong button (I don't know which one) and thus created a New Text Document.txt file. Later, I tried to recreate the event but couldn't find the right key combination. Maybe there is a shortcut. Jul 26, 2019 at 6:36
12

This isn't a hotkey as such but can be accomplished entirely on the keyboard and doesn't require any programs or system changes:

ALT+h, w and then press or as many times as necessary.

1
4

You can also do this:

Shift + F10(it will open context menu)

And then press w then t

1
  • this is the first one that is no mouse, and no arrows. Thank you
    – diox8tony
    Mar 3 at 18:17
2

Another shortcut on Windows10 will be: alt+h, w - than right-click on "New Dokument" and from the dropdown menu choose "Add gallery to QuickAccess Toolbar". Now the whole dropdown menu is accessible on every WindowsExplorer Window at the very, very top left of the window. Now whenever you need to open a WinExplorer window, you can add a Text File (or other stuff) with just 2 klicks. For Win10 (not tested on older Operating Systems) Hope this helps somebody.

2
  • Alt+H, W was answered by pyrmont days ago
    – phuclv
    Sep 23, 2018 at 14:02
  • @phuclv I don't think @NikosNachos is repeating the Alt+H, W answer. The details of the answer are to add the function to the Quick Access Toolbar putting the desired functionality within 2 keystrokes (eg Alt, 3) rather than 8 (eg Alt, h, w, dwn, dwn, dwn, dwn, dwn).
    – Josh Gust
    Jan 28, 2019 at 22:48
1

I use QTTabBar.Open QTTabBar options. Keyboard Shortcuts. Scroll down to Create a new txt file. It has assigned Ctrl + Shft + T already. Highlight and change it to F8 or any other. Done. In explorer press F8 and it creates "New Text Document"

1

This is the autohotkey script I'm using,

  • Works on file dialogs (save as / open file)
  • Works even though a file is selected
  • Works even though cursor is positioned off screen

.

;   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

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!

2
  • This does not seem to work if there are not any files in the current folder. Any ideas? May 27, 2022 at 15:20
  • Actually, this might be an issue on my end. Sometimes newly created files do not appear in directories for me... May 27, 2022 at 15:23
1

Perhaps due to my bilingual keyboard
(and also non-english default-system-language Windows),
I actually couldn't reproduce "w" then "t" answers.

So I found another similar solution instead, that works just as nietly:

Context menu (usually on the right side between "Alt" and "Ctrl"),
+ Up arrow (twice, to navigate) + Enter,
+ Up arrow (twice, again) + Enter.

One could actually even do this with Ctrl + Shift pressed:
it doesn't affect execution afaik, but exploits Ctrl + Shift + N
(which is a "create new folder") similarity to our advantage!

This also works with @Harry variation as well.

-1

1- Create a batch file (.bat) that opens notepad

2- Create a shortcut of the batch file and add keyboard shortcut for it

Batch file contents:

@echo off
start notepad.exe
exit
1
  • OP wants to have a new text file created in Explorer. He doesn't want to open Notepad.exe.
    – Fauxcuss
    Apr 25, 2022 at 21:36

You must log in to answer this question.

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