35

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
  • 416

8 Answers8

34

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
  • 555
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.

pyrmont
  • 249
5

You can also do this:

Shift + F10(it will open context menu)

And then press w then t

Harry
  • 151
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

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
  • 350
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

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