Windows – Set up an “alternative open with” hotkey in Windows 10

hotkeyswindowswindows 10

I have Windows 10. If I have highlighted a file and press "Enter", the file will be opened using the default program that I have chosen to open it.

I would like to be able to choose an alternative program to open these files if I press a different set of hotkeys, e.g., "Ctrl-Enter" or something.

For example, with my current setup, .txt files open with Notepad by default (i.e., if I press "Enter"), .html files open with Google Chrome by default, and .png files open with Windows Photo Viewer by default. I would like to be able to open .txt files and .html files with Notepad++, and to open .png files with Paint, if I highlight them and press something like "Ctrl-Enter".

Of course, I can already right-click and scroll to whatever program I want to open the files with, but since I do this very frequently, I want a faster, hot-key based approach.

Does anyone know of a way to set this up, either by something built into Windows or by some hack or other?

Thanks for any help.

Best Answer

Windows does not natively support adding a second single-action hotkey, meaning, you cannot create doing an open with 2 with just one hotkey press.

It is possible to do this with a few hotkeys though.

If your keyboard has the context menu button (usually on the bottom right of your keyboard near the alt and control keys) you can press that one to access the menu. If you do not have it, the altnernative shortcut key is CTRL-SHIFT-F10.

Once the menu is open, you'll see that the Open with has a small line below the h. This means, pressing the h key will open the Open With sub-menu. From there, pressing enter and arrow keys will allow you to open that particular file completely from the keyboard.

There are programs such as auto-hotkey which are macro based, which will allow you to perform an action based on a keypress, and some gaming keyboards also have macro keys build-in, which can be used to perform these keypresses and map it to a single key.

Alternatively, you can hack into the registry, and create a shortcut directly in the main sub-menu, but again, you cannot make this shortcut launch with a single shortcut key. But it would then be for example CTRL-SHIFT-F10, down arrow, down arrow, down arror, enter

The following registry hack will apply to every single file, nut just one type. It is possible to do it for one type too, but given that this section in the registry is a bit more complex, I've decided its not suitable for SuperUser because it takes too much explaining to do with all the possible ways it can be configured (and it is likely to break that fileformat if done improperly)

In the registry, go to HK_CLASSES_ROOT\*\shell and export this key so you have a backup in case things stop working as expected.

Create a new key. The name you give this key will be the name it will show in your context menu. Although you can write an & before a letter to underline it, unfortunately windows does not make that key a shortcut key. To write a & as real text, write &&. For this example, I'll be using _My Command and reference to it.

The next step is optional. If you'd like to add a 16x16 icon to respresent this function, you can add a String Value with Name: Icon, and Data: C:\path\to\file.ico where this path is any existing location of a .ico file.

Now, create a new sub-key to your _My Command key, and name it Command. Click it, and on the right, change thet default value to: "C:\path\to\my\program.exe" "%1". The program.exe can also be a .cmd file or anything else that executes. The %1 is a reference to the file you clicked. If for example the program you use requires more parameters to load your file, for example the file you want to open is c:\myfile.txt and the commandline would be: c:\test.exe -file c:\myfile.txt, then the default value would become: "C:\test.exe" -file "%1"

Keep in mind, that all changes to this subkey are instant changes, meaning that you can switch to your explorer, and right-click and instantly see the results. If for some reason you did not do it correctly, explorer may crash. So don't test until every step was done. Also, don't close regedit until you have confirmed that it works. If it doesn't work instantly, you need to reboot. So far I have one instance where this was required, but most of the time, these changes were instantly.

Related Question