Create a keyboard shortcut for the selected folder to “Play with VLC Media Player”

audiokeyboard shortcutsvlc-media-playerwindows 10

My digital music is stored in many folders. Currently I right-click a folder and choose "Play with VLC Media Player" to launch VLC and play all songs in the folder. I switch folders frequently so the mouse is cumbersome. Is there a way to create a keyboard shortcut to use in Windows Explorer that will launch VLC and play the highlighted folder's songs?

Best Answer

Is there a way to create a keyboard shortcut to use in Windows Explorer that will launch VLC and play the highlighted folder's songs?

One way to achieve this is to use Windows Explorer in conjunction with AutoHotkey.

In short, VLC can create a new playlist from a given folder via the command line with e.g.:

C:\Program Files\VideoLAN\VLC\vlc.exe C:\path\to\some\folder

Therefore, you can create an AutoHotkey script to run VLC with the desired folder path via a preferred shortcut. The biggest stumbling block here is likely getting the highlighted folder name to AutoHotkey. Personally, I am not aware of a simple, direct option to get this information.

However, based on an answer to this Super User Question, there is at least one possible workaround for this issue. In order to use this workaround, it is necessary to create a keyboard shortcut to the Copy path Ribbon item in Windows Explorer. This shortcut copies e.g. a selected folder's full path to the clipboard and can be used in conjunction with AutoHotkey scripts.

To enable this shortcut, find the Copy path item in the Windows Explorer Home Ribbon. Right-click the icon and select Add to Quick Access Toolbar:

Adding the "Copy path" Quick Access Shortcut - Screenshot

The Copy path item should now appear on the Quick Access Toolbar:

Copy as path added to Quick Access - Screenshot

Importantly, the Quick Access Toolbar version should now have an Alt-based shortcut automatically assigned to it. You can view these by simply pressing the Alt key e.g.:

Alt Shortcuts Overlay

In the screenshot above, the assigned shortcut would be Alt + 3. Note that the Quick Access Toolbar is placed below the Ribbon here. Normally, the Quick Access Toolbar appears above the Ribbon interface (i.e. at the very top edge of the Windows Explorer window in Windows 10). Also be aware that the shortcut (ex. Alt + 3) may be different depending on the Quick Access Toolbar items present.

Assuming the shortcut above is enabled, you can then use an AutoHotkey script similar to the one below to open a highlighted folder in VLC:

; Open a highlighted folder in Windows Explorer with VLC via a shortcut (e.g. F4).

F4::

    ; Clear any existing clipboard contents to increase the reliability
    ; of new path detection.

    clipboard :=

    ; Send e.g. Alt + 3. This should correspond to whatever shortcut
    ; is associated with "Copy path" under the Windows Explorer Quick
    ; Access Toolbar.

    Send !3

    ; Wait for the copied contents to register.

    ClipWait

    ; Run VLC with a folder name as an argument to automatically add
    ; items in that folder to a playlist.
    ;
    ; %clipboard% is the current contents of the clipboard (ideally a folder path).

    Run, C:\Program Files\VideoLAN\VLC\vlc.exe %clipboard%

Return

Caveats

Regarding the example script above:

  • As written, it only works correctly with single folders (VLC produces an error if multiple folders are selected).

  • It apparently needs to be reloaded if the Windows Explorer Copy path Quick Access Toolbar shortcut is removed, then re-added for some reason.

  • Sending non-media files to a VLC playlist may cause issues with VLC playback.

  • A folder should already be highlighted when you press e.g. F4.


References

List of Keys (AutoHotkey)

Run/RunWait (AutoHotkey)

Clipboard and ClipboardAll

Related Question