AutoHotkey Community

It is currently May 24th, 2012, 7:30 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: March 24th, 2005, 6:12 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Regedit help
PostPosted: November 26th, 2006, 10:13 pm 
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!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2006, 12:41 pm 
Good stuff!!
Now, how to delete the reg entry please?
(only for test, the script is really good) :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2006, 1:04 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
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.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2006, 10:30 pm 
Thank you, PhiLho!
Maybe you know also how to create in the Explorer shell menu the initial underlined, like
&createMp3....
createMp3...
Thanks in advance.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2006, 1:56 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Well, you gave the answer yourself:
[HKEY_CLASSES_ROOT\AllFileSystemObjects\shell\Create Playlist]
@="Create &Playlist"

Put the & wherever you want.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2006, 8:06 pm 
Thank you, PhiLho.
I'm prudent with .reg! :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 29th, 2006, 4:32 pm 
Last but not least, is there any way to insert an icon in the context menu (appskey)?
Thanks in advance.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 29th, 2006, 6:13 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
No, you have to write a real shell extension for that (AFAIK).

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Bug/Function?
PostPosted: January 16th, 2007, 4:41 am 
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


Report this post
Top
  
Reply with quote  
 Post subject: sub menus
PostPosted: January 26th, 2007, 10:02 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 27th, 2007, 9:14 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
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.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject: submenus
PostPosted: January 27th, 2007, 11:22 am 
I thought it would be easier.

Thanks for the answer anyway :)
bye


Report this post
Top
  
Reply with quote  
 Post subject: randomize
PostPosted: March 4th, 2007, 5:13 am 
does anyone know how to tweak this script so that the playlist is randomized?


Report this post
Top
  
Reply with quote  
 Post subject: Cannot get it to work
PostPosted: March 5th, 2007, 10:54 pm 
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.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Relayer, tic and 10 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group