[SOLVED] Opening music files folder with VLC Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
SyntaxTerror
Posts: 19
Joined: 23 May 2017, 12:55

[SOLVED] Opening music files folder with VLC

02 Jun 2017, 21:47

Hello.

I am quite new to AutoHotKey, but I used the macro editor PhraseExpress and have basic knowledge of programming.

I already searched this forum and the web, but couldn't find an answer to my question:

Is it possible for AutoHotKey to make VLC Broken Link for safety Media Player open a folder full of music files (MP3) and read them all?
I am using Windows 7 and usually, I right-click a folder containing my music files and choose "Read with VLC" in the context menu. I would like to do the same thing with an hotkey.

Can anybody tell me if it is possible, and eventually give me the code to achieve this?

Thanks.

[EDIT] A very easy solution is to use:

Code: Select all

^Numpad1::run "C:\Program Files\VLC\vlc.exe" "D:\Musique\Electro"
ie. pressing Ctrl + NumPad1 opens the folder "Electro" with VLC

Adding these options lauches VLC minimized to the tray and plays songs randomly (more options can be found here: wiki.videolan.org /Documentation:Command_line (outdated) and here: wiki.videolan.org/VLC_command-line_help):

Code: Select all

^Numpad1::run "C:\Program Files\VLC\vlc.exe" "--qt-start-minimized" "--random" "D:\Musique\Electro"
To start VLC minimized to the taskbar, this script has to be used:

Code: Select all

^Numpad3::
run "C:\Program Files\VLC\vlc.exe" "D:\Musique\Reggea"
WinWaitActive,ahk_exe vlc.exe
WinMinimize
Return
By the way,

Code: Select all

"C:\Program Files\VLC\vlc.exe" "D:\Musique\Electro"
can be put as the "target" of a shortcut and have the same effect (options can be added as above, instructions to modify shortcuts here: windows.tips.net /T010869_Changing_Shortcut_Properties.html).

Good luck.
Last edited by SyntaxTerror on 16 Jun 2020, 04:54, edited 3 times in total.
A_AhkUser
Posts: 1118
Joined: 06 Mar 2017, 16:18
GitHub: AAhkUser
Location: France

Re: Opening music files folder with VLC  Topic is solved

03 Jun 2017, 00:18

Hi,


You might be interesed in VLC Open folder via command line/context menu.
The run command allows you run an external program.
You can hard code the run command target parameter or define both VLCPath and folder variables on the top of your script and use an expression.

Code: Select all

VLCPath := "blablablabla" ; <<< replace this by the path of your vlc executable
folder := "blablablabalbal" ; <<< replace this by the path of your folder
return ; end of the auto-execute section (after defined all nedded variables, the script will simply wait for the hotkey below to be triggered)

!i:: ; ALT+I hotkey (for example, modify it according to your preferences)
run % """" . VLCPath . """" . A_Space . """" . folder . """" ; using an expression, the dot operator is used to concatenate strings
; it is necessary to specify two consecutive quotes inside a literal string for include a quote-character in an expression
; A_Space is a bulit-in variable which contains the space character
return ; end of the subroutine
Hope this helps
my scripts
BoBo
Posts: 3620
Joined: 13 May 2014, 17:15

Re: Opening music files folder with VLC

03 Jun 2017, 02:23

A_AhkUser wrote:Hi,


You might be interesed in VLC Open folder via command line/context menu.
The run command allows you run an external program.
You can hard code the run command target parameter or define both VLCPath and folder variables on the top of your script and use an expression.

Code: Select all

VLCPath := "blablablabla" ; <<< replace this by the path of your vlc executable
folder := "blablablabalbal" ; <<< replace this by the path of your folder
return ; end of the auto-execute section (after defined all nedded variables, the script will simply wait for the hotkey below to be triggered)

!i:: ; ALT+I hotkey (for example, modify it according to your preferences)
run % """" . VLCPath . """" . A_Space . """" . folder . """" ; using an expression, the dot operator is used to concatenate strings
; it is necessary to specify two consecutive quotes inside a literal string for include a quote-character in an expression
; A_Space is a bulit-in variable which contains the space character
return ; end of the subroutine
Hope this helps
The 2017th noob-friendly comments award goes to France! :clap: :clap: :thumbup: :clap: :clap:
Thx for taking that time. Much appreciated :)
garry
Posts: 2399
Joined: 22 Dec 2013, 12:50

Re: Opening music files folder with VLC

03 Jun 2017, 05:59

thank you , another idea , start m3u file ( I use VLC as default player )

Code: Select all

setworkingdir,%a_scriptdir%
Extensions:= "mp3,wav,aac"      ;- some music extensions
PRESELECT  =%a_desktop%         ;- search from here

FileSelectFolder,MF,%PRESELECT%
if MF=
  return
SplitPath,MF, name, dir, ext, name_no_ext, drive
F1=%A_desktop%\%name_no_ext%.m3u
ifexist,%f1%
   filedelete,%f1%
setworkingdir,%MF%
Loop, %mf%\*.*, 0, 1
  {
  If A_LoopFileExt in %Extensions%
    e4x .= A_LoopFileFullPath "`r`n"
  }
if e4x<>
  {
  fileappend,%e4x%,%f1%
  run,%f1%
  }
else
  msgbox, 262208,Music-Files ,NO Music-Files found at`n%mf%
return
A_AhkUser
Posts: 1118
Joined: 06 Mar 2017, 16:18
GitHub: AAhkUser
Location: France

Re: Opening music files folder with VLC

04 Jun 2017, 17:20

BoBo wrote:The 2017th noob-friendly comments award goes to France! :clap: :clap: :thumbup: :clap: :clap:
@Bobo haha very funny :lol:
There are so many shades of gray^^ I didn't notice... At this stage it is not a script commented: it is a comment scripted... :crazy:

@garry cheers for your solution. Sometimes I listen radio via VLC and I noticed that the files provided have an .m3u extension; however, I didn't know these ones was kind of playlist: I was pretty sure I get the same as an mp3 or an exe compiled file if I opened it in the notepad. Thanks for sharing this.
my scripts
User avatar
SyntaxTerror
Posts: 19
Joined: 23 May 2017, 12:55

Re: Opening music files folder with VLC

12 Jun 2017, 12:06

@Bobo: actually, I am not a complete noob and I understood what A_AhkUser wrote.

I could adapt quickly his code to have a script playing different folders by pressing Alt+Numpad1, Alt+Numpad2, Alt+Numpad3, etc.

Code: Select all

VLCPath := "C:\Program Files (x86)\VLC\vlc.exe"
folder1 := "C:\Users\Olivier\Music\Electro new"
folder2 := "C:\Users\Olivier\Music\Electro old"
folder3 := "C:\Users\Olivier\Music\Reggea"
return

!Numpad1::run % """" . VLCPath . """" . A_Space . """" . folder1 . """"
!Numpad2::run % """" . VLCPath . """" . A_Space . """" . folder2 . """"
!Numpad3::run % """" . VLCPath . """" . A_Space . """" . folder3 . """"
return
@garry: I never understood how to deal with these m3u thingies... Also I think, with all respect, that the script above seems clearer and simpler than yours.

Thanks to all for your help. :)
A_AhkUser
Posts: 1118
Joined: 06 Mar 2017, 16:18
GitHub: AAhkUser
Location: France

Re: [SOLVED] Opening music files folder with VLC

12 Jun 2017, 12:59

Hi SyntaxTerror,

I'm the first happy to know it helped you. Btw you also can use arrays. You said you have basically knowledge of programming, well, in ahk, array syntax is the same as in the majority of other languages.

Code: Select all

VLCPath := "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe"
folders := ["C:\Users\Jérémy\Music\K-Chill, KHip Hop, KPop, Korean Mellow", "C:\Users\Jérémy\Music\albums\The Bronx Zoo", "C:\Users\Jérémy\Music\HipHop, Chill HipHop"] ; an array of folders
return ; end of the auto-execute section

!Numpad1::
!Numpad2::
!Numpad3::
StringRight, index, % A_ThisHotkey, 1 ; retrieves one character from the right-hand side of a string and stores it in index
run % """" . VLCPath . """" . A_Space . """" . folders[index] . """"
return

Cheers.
my scripts
BoBo
Posts: 3620
Joined: 13 May 2014, 17:15

Re: [SOLVED] Opening music files folder with VLC

12 Jun 2017, 13:57

I never understood how to deal with these m3u thingies...
AFAIK those are standard text files you can write on the fly using AHK - eg. to create your own "jukebox".

https://en.m.wikipedia.org/wiki/M3U
User avatar
SyntaxTerror
Posts: 19
Joined: 23 May 2017, 12:55

Re: [SOLVED] Opening music files folder with VLC

13 Jun 2017, 01:32

A_AhkUser wrote:I'm the first happy to know it helped you. Btw you also can use arrays. You said you have basically knowledge of programming, well, in ahk, array syntax is the same as in the majority of other languages.
Thank you for pointing this, I may use it in the future if I get into more complex things, but I guess that for only three folders, the best is to stick with a simpler version of the script.
BoBo wrote:AFAIK those are standard text files you can write on the fly using AHK - eg. to create your own "jukebox".

https://en.m.wikipedia.org/wiki/M3U
Thank you also for explaining this. I learnt something new today. ;)

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Botsy, Dario91, deloren, kiwiboost, patilizer, sebbulon, vebmaster and 67 guests