I noticed that a regular button won't run if there is a COPY command present (among others) but no item selected. This can be fixed by adding a dummy SELECT command at the top or by removing the COPY command(s) alltogether (which breaks the button of course).
It seems to me that there is some logic involved, which checks for specific native commands and a selection being present before running the button. But with that, you really end up scratching your head why a button won't run at least the first line it contains. I wonder if that special handling is still required? Could it be removed to make things more transparent and intuitive in general and in conjunction with scripted commands?
Copy needs a selection else it has nothing to do. This is an intentional feature, mainly so the normal copy, move, rename etc. buttons on people's toolbars will disable to show they need a selection.
Why are you using copy without a selection? Is there a situation where that makes sense?
The button uses a script command to select things at first and then there is Copy to process the selected items.
SelectEx FROMFILE D:\filenames.txt
Copy TO D:\my\dest
The starting point of the button is indeed no selection, but it will not run, unless you remove all copy commands or insert a native Select command at the top. So wether the button will run, depends on existence of Copy/Select statements in the button, which I find strange. What do you think?
The "should I enable this button?" logic has no way to know that your custom SelectEx command might select things, so it will assume nothing is selected, see the Copy command, and disable the button.
(That's also why adding a dummy Select command works. But I don't think there is a way of flagging a script command to act in the same way.)
I guess we could add to @disablenosel so there's a way to prevent this, if you want a cleaner workaround than either adding the dummy Select or moving everything into a script.
However, selecting things to change what other commands do is problematic anyway. Doing everything from a script gives you a better way. Scripts can explicitly add to the list of files the Command object will use, then run a command. In fact, the Command object can load a list of files, so you don't need SelectEx or much custom script code at all here.
Something like:
cmd.ClearFiles();
cmd.AddFilesFromFile("D:\\filename.txt");
cmd.RunCommand("Copy TO D:\\my\\dest");
I just noticed, the occurence of the native "Clipboard" command automatically disables a button, though there are other commands that follow it and which do not depend on a selection, I guess that's what you were talking about. @disablenosel has not been added to this button. It also requires the dummy "Select" at the top to make the button work (and enable it for all time).
Though I find this "auto" disable thing a bit special, it is quite a good indicator, that there is a problem with the button in it's current state and the commands contained. So now I wonder why the button I initially mentioned, the one that uses Copy, does not disable like that, it just does nothing when pressed (not even the first command is executed).
Is that some special case/bug maybe?
What is a custom button, one that uses more than one native command?
Wouldn't things be more clear if buttons get disabled only if @disablenosel is present, but no selection?
The latter probably is due to the history of how things evolved. It still might be something to straigten out in the future (by adding @disablenosel to all buttons that require it in stock config and by removing the magic that is going on, if specific commands are used).