Adding Items to the Context Menu

Discussion in 'Windows 7' started by LFDDatMyDigitalLife, Feb 13, 2011.

  1. LFDDatMyDigitalLife

    LFDDatMyDigitalLife MDL Novice

    Aug 19, 2010
    40
    5
    0
    #1 LFDDatMyDigitalLife, Feb 13, 2011
    Last edited by a moderator: Apr 20, 2017
    Hi ;),

    I would like to add an item in the context menu (right-click in explorer) but only for FLAC files !
    I already tried a lot of registry manipulations but still no success o_O

    The only way I found is to add my item in the following registry key:

    Code:
    HKCR\*\shell\extractflac > Default = [Extract FLAC Files]
    HKCR\*\shell\extractflac\command > Default = [extractflac.bat "%1"]
    
    But this item is now available for all my files and that's not very clever! Does anybody knows how to do?

    PS: I tried to add a shell key in the HKCR\.flac registry key but no effect (I did not restart the computer). I also tried to add my item in the HKCR\foobar2000.flac shell registry key but after restarting, foobar clean up my item (protection ?)
    PPS: Windows 7 x64 Ultimate - Foobar2000
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. Enigma256

    Enigma256 MDL Senior Member

    Jan 17, 2011
    354
    300
    10
    #2 Enigma256, Feb 14, 2011
    Last edited by a moderator: Apr 20, 2017
    * will apply to all files, so you want .flac. However, if .flac's default points to another class (e.g., foobar2000.flac), then the change must be made in that class and not in .flac. So you need to make the change in foobar2000.flac. It seems strange that foobar2000 would remove that entry, but if it is doing it, then you could try adding it to HKCU\Software\Classes\foobar2000.flac (create the key if it doesn't exist). The reason this might work is that there is a chance that if foobar2000 really is deleting the entry, it'll delete it from HKLM and not HKCU (HKCR is actually just a virtual key that is comprised of the system-wide entries found in HKLM, with the user-specific entries in HKCU overriding any overlaps).
     
  3. LFDDatMyDigitalLife

    LFDDatMyDigitalLife MDL Novice

    Aug 19, 2010
    40
    5
    0
    #3 LFDDatMyDigitalLife, Feb 14, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Thank you very much, it works! :cool:

    Maybe you could answer to another question, you or anybody... It's complicate to explain in English so tell me if you don't understand.

    I wrote a little batch script that extract individual flac songs from a flac album (one file for the entire album) by using "Shntool".
    Here is the code of "extractflac.bat":
    Code:
    @set FLACFILE=%1
    @set CUEFILE=%FLACFILE:flac=cue%
    @set PATH=%FLACFILE:~0,-6%"
    @md %PATH%
    
    c:\windows\shntool split %FLACFILE% -f %CUEFILE% -d %PATH% -t "%%n. %%t" -o flac -m :-/_\_*x?-"'
    
    @pause
    %1 is the path of the file with quotes (e.g. "d:\Music\The Beatles\White Album.flac") and it is send to the script by using the context menu (right-click on the file, "Extract FLAC" option) thanks to you !

    Code:
    HKCU\Software\Classes\foobar2000.flac
    HKCU\Software\Classes\foobar2000.flac\shell
    HKCU\Software\Classes\foobar2000.flac\shell\extractflac > Default = Extract FLAC
    HKCU\Software\Classes\foobar2000.flac\shell\extractflac\command > Default = extractflac.bat "%1"
    Now, when I highlight more than one flac file and that I select the "Extract FLAC" context menu item, my script is open for each file separately at the same time.

    So what must I do to have just one script executing each file one after an other ? Is there a value in registry to change or is it a bad batch code ?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. LFDDatMyDigitalLife

    LFDDatMyDigitalLife MDL Novice

    Aug 19, 2010
    40
    5
    0
    I suppose this is not really the place for such question :)

    Thanks anyway for your first answer !
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Enigma256

    Enigma256 MDL Senior Member

    Jan 17, 2011
    354
    300
    10
    #5 Enigma256, Feb 16, 2011
    Last edited: Feb 16, 2011
    Your method of adding something to the context menu is creating a shell "verb" (anything the follows the "[class]\shell\[verb]\..." structure), and shell verbs can ONLY act on one item. There is no way to do what you want with shell verbs.

    To do what you want, you need a shell extension. You need to program a DLL implementing IContextMenu in COM, in C or C++ (this is an in-process DLL so you have to use proper, moral native code and not that disgusting immoral .NET crap), and register that in [class]\shellex\ContextMenuHandlers.