Possible to give warning, when using inproper filetype?

I just set up a new hotkey, which will open audio files in an audio editor. The usual "path.." "%1" thing. Can i specify some code, to have that hotkey only to react at "audio" filetypes & otherwise give out a warning, like "please only use audio files" & do nothing? I didn´t try to open wrong file types with that function, but it´s likely it will happen sometimes.

You might be able to do it adding a file type action (verbs) and a button which runs the verb (using the contextmenu command).

Have the verb defined for all files & folders so that it does nothing, and then define it again on the types you want something to happen for.

I've not tried it but that should work in theory.

Hmm, i have not much of an idea where to place the verb (in the files & folders context menu?) & how it should exactly look like.

Something like: CONTEXTMENU=VERB=empty? Sorry, the description in the F1 help is somewhat short on that topic. :frowning:

Well ahem...

I'm not about to say that LEO of all people still doesnt have a thing or four to teach me about Opus, but I don't see how [u]Opus[/u] actually gives users the ability to 'add' verbs to the defined list of actions for files... At least, the File Types editor interface in Opus doesn't seem to let ME "add" new actions... In fact, the Actions tab doesn't even appear at all for me in the All files and All files and folders edit windows...

So.......... while Leo or somebody else may come along and say there's an easier and obvious way that I just don't know about, I can tell you something like this would work (both in and OUT of Opus via context menu entries) with some very minor registry tweaking.

First: a registry entry ala Leo's suggestion to add a fake-out action for "all" file types... but rather than do just "nothing"... cause Opus to generate the sort of warning message you mentioned:

[code]Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT*\shell\special]
@="Special Menu Action Text"

[HKEY_CLASSES_ROOT*\shell\special\command]
@=""C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /cmd @confirm Please use only supported audio file types..."

[/code]
Note that the 'verb' name is actually the name of the key (in this example - special) placed under the 'shell' parent key (which you may or may NOT have under the * file type / class key...). You can change that name to whatever makes sense for YOU, but the name of the verb isn't that relevant. If you ever care about using this in the 'Context Menu', then it's the text value you specify in the default (@) string value located in the verbs key itself...

Second: for the actual program you want to run on 'audio' files, there's a few ways you can do it. One of the easiest, depending on how many file types you work with, may be to place the SAME VERB NAME as you did above under the audio PerceivedType... albeit, with the path and args for the actual program you want to run... i.e:

[code]Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\audio\shell\special]
@="Special Menu Action Text"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\audio\shell\special\command]
@=""C:\Program Files\mediainfo\mediainfo.exe" "%1""

[/code]
This method will "work" with a relative minimum of registry fuss since the PerceivedType is sort of a Windows based version of Opus' File Type Groups where changes made to this one key can affect 'many' different file extensions associated with this perceived filetype... Otherwise, you can add a similar bit of registry info to the individual descriptor keys associated with each of the file extensions you're concerned with, but that could be more work if you ever want to make changes... shout if you want help going that way.

Lastly: for the actual button method of actually using this stuff, you can use a button like the following that calls the verb you've essentially just defined twice above to do different things depending on what file type is selected when clicking the button:

<?xml version="1.0"?> <button display="both" icon_size="large" label_pos="right"> <label>Test Button</label> <tip>Test Button</tip> <icon1>#pathfield</icon1> <function type="normal"> <instruction>ContextMenu VERB special</instruction> </function> </button>
NOTE: the stuff I've shown above is just a set of examples, you'd obviously want to adjust the actual warning message and maybe the default text in the first block of code before merging to your registry... same goes for the ACTUAL program path and command line arguments for the stuff in the second block of code, and then finally... change the label and icon stuff for the Opus button code shown in the third block of code.

Does that more or less do what you wanted to do?

Steje, thank you very much, this looks promising. However, i´m not sure how to make the changes in Regedit. I made a new key in the HKCR, but i´m not sure, what type the rest has to be, eg. DWORD or something else?

Or can i paste the coder into a reg key & "import" it in admin mode?

If you add an Run an application (supported in Opus and Explorer)-type item to a filetype's context menu then you will create a verb for free. (Or, at least, it creates something which you can run via the ContextMenu command. Not sure if it's technically a verb or not. Originally I had in mind adding verbs via the Action tab, but when I went to look it turns out you can't. :slight_smile: I thought Steje got me there but then I tried the Context Menu route, just in case, and it works. :slight_smile: )

To create the generic "do nothing" (or "show warning" if you want) one, open the All Files and Folders type, go to the Context Menu tab and create your command. Make a note of the name you've given it. Avoid spaces in the name as they might complicate things.

(Note: Don't do this to the All Files type as it is Opus-specific and you can't create verbs for it like you can the All Files and Folders type.)

Then add a context menu item with the same name to the actual filetype you're interested in.

Remember that you can't use Opus commands (unless you run them via dopusrt.exe like in Steje's example) and you can't use Opus command-codes, either, as these things have to work in Explorer as well. You can use "%1" to insert the filepath into the command as Explorer understands that. You can't use Opus-specific codes like {filepath}.

If you now right-click a random file type then you'll just see the generic item which does nothing (or displays a warning or whatever).

If you right-click a file of the type you added the specific command to, you should see two menu items with the same name, probably in different places in the menu, because both items apply to that file. Kinda confusing but then this is a bit of a kludge. :slight_smile:

Now make a button which runs something like this:

ContextMenu VERB="LeoTestTest"

(LeoTestTest is the name of the thing I added.)

If you click that with just the specific file types selected then it'll run the specific command on each of them.

If you click that with random stuff (or a mixture of random and specific files) selected then the generic do-nothing/warning action will be run once for every selected item.

At least, that seems to work. I've not tested it much so put it through its paces before you rely on it for anything important.

[quote="leo"]To create the generic "do nothing" (or "show warning" if you want) one, open the All Files and Folders type, go to the Context Menu tab and create your command. Make a note of the name you've given it. Avoid spaces in the name as they might complicate things.
[/quote]

Problem is, i have absolutely no idea, what that command should look like, sorry. I have no idea which program to point at or which path to use. Can i just write "DNOTHING=do nothing"? I don´t think so. :frowning:

If you want it to do nothing you might be able to leave the command blank... That might confuse some things though. Safest thing is probably to run a command which doesn't do anything. dopusrt.exe without any arguments is a good example:

"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe"

I made the new context menu entry, but it won´t stick. After closing the editor: no new entry, back to edit mode -> entry is disappeared. Maybe such empty commands will be discarded?

Ah, yes they will. It's got to contain a command so use dopusrt.exe (without any args) as a do-nothing command.

Leo, i had your example, maybe i got you wrong somehow? Here´s a few screenshots

After reentering the edit mode the new command is gone.

If you're on Vista with UAC enabled, do you get a UAC prompt?

If you're not on Vista (or UAC is disabled), do you have admin access? You might need it to modify the All Files and Folders type.

Leo, thanks again. I started some small file manager, which i use sometimes for jobs "outside" opus (for instance installing new opus versions, when it is shut down), it starts in admin mode. The thing is, when having Opus started that way, it looks like it does not actually run in admin mode, so that explains it.

Now i made that new verb, & it also does nothing (i don, t know how to include the warning message, though). Then i tried following, which is obviously wrong:

I placed this context menu under .wav & .mp3 files, assuming that the previously definded verb "nothing" would work. But i don´t see much of a difference. When trying on non-music files it does nothing, but when using it with mp3s, a "open with" dialog comes up. :blush:

Thanks steje & Leo!

I made steje´s #1 & 2 codes into reg files & imported them into the registry. Now i can use a hotkey & it works ok, including the proper error message!

I didn´t really get the "verb" thing yet, but can see how it approximately works. Both solutions are quite similar. So now i have that error message, except i handle wav or mp3, as intended.

If now i wanted to make a similar thing with image files (best would be, if a whole file type could be used), would i have to make new keys in the registry or partially reuse the new ones? I´m not sure about that. Btw, i wonder, where the function takes the information from to evaluate which file type is "legal". Is it the "...\audio\shell" part?

:sunglasses:

@Leo:

Cheater... LOL!

@abr:

Both solutions are actually the same... just configured in different ways. If you look at the first reg file I posted above, you'll see the command it's running in order to show you the sort of warning message you wanted:

"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /cmd @confirm Please use only supported audio file types...

...which if you look at Leo's suggestion for the "do nothing" action to be added to the All files and folders filetype, it's the same dopusrt.exe program, but with the thing that actually generates the warning, which is the Opus @confirm command modifier, followed by the warning message text.

Don't get hung up about the "verb" thing... the bottom line is that using Leo's method, the NAME of the context menu entry that you would add to both the All files and folders filetype, and the filetypes you want to run the 'actual' command need to be the SAME.

So looking at your screenshots above, it seems you were going about it slightly wrong... in the example you showed for what you said you placed under the .wav & .mp3 file types (Weidergabe - in order to run Windows Media Player)... I ALSO see you have an entry in there to run an action called Nothing, which is sort of useless as you've found out... What we were trying to tell you was to basically create ANOTHER Context Menu action named Weidergabe under the All files and folders filetype, which instead of running the actual program you want to run when audio files are selected, run the sort of dopusrt.exe command mentioned above.

The point of all this is that you can then have a single Opus button or hotkey that runs ContextMenu VERB Weidergabe, but which behaves differently depending on which type of file you've got selected because the verb/action/command Weidergabe itself is in turn defined to run a DIFFERENT program for .wav & .mp3 files than "everything else".

FWIW: the point of why I mentioned the registry based method of adding the "real" command to the "audio\shell" related registry key, was exactly so that you wouldn't have to add the command to multiple individual filetype extensions (wav, mp3, etc)... if you want to do something similar for "images" then there is also an image key under the SystemFileAssociations key that may be easier to work with than adding whatever program you want to run to each image file extension in Opus' filetype editor...

[quote="steje"]
Both solutions are actually the same... just configured in different ways. If you look at the first reg file I posted above, you'll see the command it's[/quote]

Yeah, i know. But after getting stuck with the "verb" thing i tried the registry route, which was basically cut & paste :slight_smile:

I knew how Leo meant it, using the verb twice, like a filter, problem was the declaration of the verb itself. The "nothing" thing on the screenshot was before i switched to your approach, it surely doesn´t make any sense that way.

Btw, the Windows Media Player entry was there by default, since i practically never use WMP, but Winamp or recently KMplayer.

That sounds good, i will have a look at that. Anyway, this works now as intended. Thank yous very much.

About the "verb" thing...

verb = "name of the reg key created under a file types shell key" - or in the case of the reg example I gave, not an actual file types key, but rather a 'perceived' file type 'group' key ('audio' - or if you want another one, 'image').

verb also = "name of context menu action created in Opus File Type Editor" - as long as you create an action of type Run an application (supported in Opus and Explorer)...

To observe the tracks of how the method Leo suggested is effectively the same as importing the reg key data... take a look at the action you defined under the 'All files and folders' group in Opus... you'll find that the "name of that context menu action" has now been created as a reg key underneath the HKEY_CLASSES_ROOT\AllFilesystemObjects\shell key... which is another place you could have defined the "do nothing" verb/command/action thingy instead of what my first reg export did under the HKEY_CLASSES_ROOT*\shell key...