AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Create Playlist - Explorer shell menu extension
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Serenity



Joined: 07 Nov 2004
Posts: 1271

PostPosted: Thu Mar 24, 2005 5:12 pm    Post subject: Create Playlist - Explorer shell menu extension Reply with quote

Here is a simple script that creates an .m3u playlist file via the Explorer shell menu. If the user right-clicks on a folder, it will create an m3u list based on the audio files inside that folder. If the user right-clicks on a file, it will create an m3u list based on audio files that reside in the files current directory.

This script can be installed uncompiled by specifying the path to AutoHotkey.exe in the command line. Sample registry keys required to link it to the shell menu are posted below along with the source code.

Recognised audio formats:
WAV,AIFF,AIF,IFF,SVX,SND,AU,VOC,CUE,OGG,MPC,MP+,MPP,MP3,MP2,MP4,M4A,AAC,FLAC,FLA,APE,MAC,WV,SPX,SID,CDA

Changelog:
* updated to write full path to audio files in m3u file
* updated to work with a wide range of audio formats
* updated to only create an m3u file if audio files exist in current directory
* script updated to get path details from clicked-on item
* script now titles the created .m3u file with the name of the directory it was created in

Code:
splitpath, 1, file, dir
 
filegetattrib, attr, %1%
if attr contains D ; launched from a directory
{

  m3u = %dir%\%file%\%file%.m3u
 
  loop, %dir%\%file%\*.*
  {
    splitpath, A_LoopFileName, , , ext
    if ext in WAV,AIFF,AIF,IFF,SVX,SND,AU,VOC,CUE,OGG,MPC,MP+,MPP,MP3,MP2,MP4,M4A,AAC,FLAC,FLA,APE,MAC,WV,SPX,SID,CDA
    {
      filelist = %filelist%%A_LoopFileLongPath%`n
      count++
    }
  }   
 
  if count = ; no audio files found
    return

  sort, filelist
 
  filedelete, %m3u%
  fileappend, #EXTM3U`n%filelist%, %m3u%

}
else ; launched from a file
{

  ; get the current folder for the m3u name:
  stringsplit, array, dir, \
  folder := array%array0%   
  m3u = %dir%\%folder%.m3u

  loop, %dir%\*.*
  {
    splitpath, A_LoopFileName, , , ext
    if ext in WAV,AIFF,AIF,IFF,SVX,SND,AU,VOC,CUE,OGG,MPC,MP+,MPP,MP3,MP2,MP4,M4A,AAC,FLAC,FLA,APE,MAC,WV,SPX,SID,CDA
    {
      filelist = %filelist%%A_LoopFileLongPath%`n
      count++
    }
  }   

  if count = ; no audio files found
    return

  sort, filelist
 
  filedelete, %m3u%
  fileappend, #EXTM3U`n%filelist%, %m3u%

}
return



Compiled:

Code:
REGEDIT4

[HKEY_CLASSES_ROOT\AllFileSystemObjects\shell\Create Playlist]
@="Create Playlist"

[HKEY_CLASSES_ROOT\AllFileSystemObjects\shell\Create Playlist\command]
@="\"x:\\path to exe\\create m3u.exe\" \"%1\""


Uncompiled:

Code:
REGEDIT4

[HKEY_CLASSES_ROOT\AllFileSystemObjects\shell\Create Playlist]
@="Create Playlist"

[HKEY_CLASSES_ROOT\AllFileSystemObjects\shell\Create Playlist\command]
@="\"C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\" \"x:\\create playlist.ahk\" \"%1\""

_________________
"Anything worth doing is worth doing slowly." - Mae West
Back to top
View user's profile Send private message Visit poster's website
sociableorg
Guest





PostPosted: Sun Nov 26, 2006 9:13 pm    Post subject: Regedit help Reply with quote

Hi,

First off, thanks for posting the wonderful script. I was trying to use the registry entry script you posted for the shell extensions, but am having a problem running that script. I have saved the following into a file called playlistregedit.reg:
--------------------------------------------------------------
REGEDIT4

[HKEY_CLASSES_ROOT\AllFileSystemObjects\shell\Create Playlist]
@="Create Playlist"

[HKEY_CLASSES_ROOT\AllFileSystemObjects\shell\Create Playlist\command]
@="\"x:\\path to exe\\create m3u.exe\" \"%1\""

--------------------------------------------------------------
I have changed the path in the script to point to m3u.exe.

Now I execute regedit /s playlistregedit.reg

I am getting an error "Cannot import playlistregedit.reg: Error opening file".

Appreciate your help!
Back to top
reg
Guest





PostPosted: Mon Nov 27, 2006 11:41 am    Post subject: Reply with quote

Good stuff!!
Now, how to delete the reg entry please?
(only for test, the script is really good) Very Happy
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Mon Nov 27, 2006 12:04 pm    Post subject: Reply with quote

Technically, that's not an Explorer shell menu extension, real one require to do a Com DLL...
That doesn't remove the usefulness of your script, of course.

I can't answer sociableorg, except to double-check the format of the file. Perhaps ensure it is pure Ascii, not encoded in Unicode.

reg, to delete a reg entry, just put a minus sign (a dash, an hyphen) after the opening brace:
Code:
REGEDIT4

[-HKEY_CLASSES_ROOT\AllFileSystemObjects\shell\Create Playlist]


Mmm, I didn't knew this AllFileSystemObjects, this is useful to know.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
reg
Guest





PostPosted: Mon Nov 27, 2006 9:30 pm    Post subject: Reply with quote

Thank you, PhiLho!
Maybe you know also how to create in the Explorer shell menu the initial underlined, like
&createMp3....
createMp3...
Thanks in advance.
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Tue Nov 28, 2006 12:56 pm    Post subject: Reply with quote

Well, you gave the answer yourself:
[HKEY_CLASSES_ROOT\AllFileSystemObjects\shell\Create Playlist]
@="Create &Playlist"

Put the & wherever you want.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
reg
Guest





PostPosted: Tue Nov 28, 2006 7:06 pm    Post subject: Reply with quote

Thank you, PhiLho.
I'm prudent with .reg! Very Happy
Back to top
insert an icon in the con
Guest





PostPosted: Wed Nov 29, 2006 3:32 pm    Post subject: Reply with quote

Last but not least, is there any way to insert an icon in the context menu (appskey)?
Thanks in advance.
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Wed Nov 29, 2006 5:13 pm    Post subject: Reply with quote

No, you have to write a real shell extension for that (AFAIK).
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
pandoRa
Guest





PostPosted: Tue Jan 16, 2007 3:41 am    Post subject: Bug/Function? Reply with quote

it's nothing major, just - when I select several files at once and then try to create a playlist it crashes the Explorer :)

Is there any possibilitie to work around that?
I realy like that script, it'd be nice for selections to work
Back to top
Andras
Guest





PostPosted: Fri Jan 26, 2007 9:02 pm    Post subject: sub menus Reply with quote

Hi there folks,

I really like this solution,

But could you tell me if there is a possibility to make submenus under a shell extension in the explorer menu?

Just like WinZIP does have more options.

Thanx,
Andras
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Sat Jan 27, 2007 8:14 am    Post subject: Reply with quote

AFAIK, just by playing with the registry, no.
WinZip and others create real shell extensions, ie. plug-ins relying on Com interface (the ActiveX kind, not the com port!) to communicate with the shell (Explorer). This is beyond current AHK capabilities.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Andras
Guest





PostPosted: Sat Jan 27, 2007 10:22 am    Post subject: submenus Reply with quote

I thought it would be easier.

Thanks for the answer anyway Smile
bye
Back to top
cracksloth
Guest





PostPosted: Sun Mar 04, 2007 4:13 am    Post subject: randomize Reply with quote

does anyone know how to tweak this script so that the playlist is randomized?
Back to top
Newb42
Guest





PostPosted: Mon Mar 05, 2007 9:54 pm    Post subject: Cannot get it to work Reply with quote

I am relatively new to autohotkey but even so, for the life of me I cannot get this script to work correctly. Every time I launch the create playlist option on a music folder it does nothing. It probably is something stupidly simple that I am overlooking but any help would be appreciated.
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group