30

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

Stamimail
  • 356
  • 2
  • 4
  • 8
  • 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 `Shortcut`tab, 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 '16 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 '16 at 08: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. – Kamil Maciorowski Jul 03 '16 at 17:33
  • Another hint: `fsutil file createnew emptyfile.txt 0` – Stamimail Jun 22 '18 at 08:38
  • 1
    Although not a hotkey. I find it much faster to do `Ctrl + L` and `touch file.txt` –  Mar 16 '22 at 18:40

8 Answers8

30

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.

ak11234
  • 515
  • 1
  • 4
  • 9
  • Assuming Windows and Windows Explorer. – ak11234 Jul 04 '16 at 21:56
  • 1
    This solution is a kind of workaround. I was looking for a more direct solution, but thanks. – Stamimail Jul 07 '16 at 13:10
  • instead of doing a mouse click, it's better to press the [menu key](https://en.wikipedia.org/wiki/Menu_key) on the keyboard which is called [AppsKey in AHK](https://autohotkey.com/docs/KeyList.htm) – phuclv Sep 12 '18 at 05:04
  • 2
    The menu key should be used. The OP was asking for a "hotkey" not a mouse click. – Avatar Jan 07 '19 at 05: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. – Meraj al Maksud Jul 26 '19 at 06:36
11

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.

pyrmont
  • 237
  • 2
  • 7
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.

  • Alt+H, W was answered by pyrmont days ago – phuclv Sep 23 '18 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 '19 at 22:48
2

You can also do this:

Shift + F10(it will open context menu)

And then press w then t

Harry
  • 121
  • 2
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"

RahimGM
  • 11
  • 1
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!

tinker
  • 260
  • 2
  • 12
0

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
Jaad Chacra
  • 129
  • 2