Is it possible to reference a button's label in the Command Editor?
I want to pass the button's label value to my custom program that am calling from inside the Command Editor script (Standard Function (Opus or external)).
The linked post was about file/folder labels, not button labels/names.
I don't think there is a way to refer to the button label from within its command. You can change set label via @label or by using Evaluator code in the main label field, but can't inspect it to find out what it currently is and run different things depending on that.
Thank you but this changes the value of the button label.
What I actually need to do is retrieve and pass along the current label value without changing it.
But I realized something else: You only get the original label (ie. the one set in the button editor), not the current value. So if it has been changed before, this won't help at all...
Perhaps it might be a nice addition to get current_label as a variable as well.
Of course, a solution might be to additionally track whatever you are setting as the label in a global variable...
Thanks, but even with your example, using original_label as an command argument later in the script does not work because the variable name is passed instead of its value.
Can you possibly show an example where the value for the original_label can be passed as an argument to another non-Dopus (Autohotkey, Powershell) script?
No, it seems that I can't ...
I played around a bit more and perhaps now I understand fully what I didn't want to accept.
The original_label is only available for the refresh event, not the click event.
Therefore, even if you assign it to a variable in the @evalalways statement - which is evaluated for both events - that variable will be set for the refresh but fail for the click, so it can't be used further down...
Sorry, I'm out of ideas; I'd try something with a global variable as a workaround.
Good luck!
What's the actual aim? There might be a better way to do it.
For example, if you only want to define a string once and have it in both the label and the command itself, you can do that by defining a variable in the button and using that in the command and setting the label to it. No need to read the label back in that case.
The aim is to use the existing button(s) label's original_label value as an input argument to an Autohotkey (or other non-dopus) script.
Assigning a value to a variable and then using the variable to both set the label's value and use the variable, later in the script, does work. But with few hundred already defined button labels, setting a variable to it's unique label value inside every script is tedious.
Simply stated, having the ability to reference the original_label (or current_label) value, later in the script, would be the ideal solution. I realize you said earlier this was not possible. Perhaps in the future this could change?
@grosner sorry, I still don't quite understand this. Correct me if I'm wrong, but unless these buttons have been created in some dynamic way, you had to place the labels manually, right? So its value is constant. Also, to include the new code, you would still have to go through the trouble of manually editing each of the buttons...where you could manually set the same value that you manually set as the label value.
Out of curiosity and if is not too much trouble to you, could you give an example of real use where it is possible to contemplate this scenario in action?
Scenario:
Like so many other features, the ability to add custom buttons to Dopus toolbars is extraordinary!
In my case, I have a button menu containing over 100 uniquely labeled (named) buttons. These buttons are named something like: 02.02 Tickers, 02.03 Indices ... 06.00 Holdings 01 - 20, and so on, with each button calling the same Autohotkey script that accepts several arguments, including one argument, having the same value as the button label (e.g. "02.02 Tickers").
The fun starts when creating or redoing the names or sequences (periodically needed).
This takes several tedious steps:
Open the command editor
Update the button label's value
Copy the new button label's value to the copy buffer
Position the mouse cursor inside the function editor
If required, select old (non-contiguous) text to be overwritten
Paste the previously copied value.
Check the new value for accuracy.
Run the script to ensure correct value is passed along.
Close the command editor
Repeat for each of 100+ buttons.
With an available function accessible variable like "original_label", I could edit the label value in one place (the Label field.) This could substantially reduce editing time.
I hope this explains my scenario.
Despite this thread's length, and the generosity of contributions, I feel the need is quite simple:
Reference a button label's **value** (its name), from inside a function (or user command), by using a variable that can be utilized elsewhere in the function, as an argument without having to use @label in the function.
PS: I realize that, alternatively, it is possible to edit the Dopus XML customizations file. That approach is a topic for a different discussion.
It seems like a task that can be accomplished as follows: a script that reads these labels (from a file?) that change periodically and, from there, generates a new XML DO toolbar file (or modifies an existing one, depending). That's it, programmatically building/editing a toolbar. It can be relatively simple to do, especially if the buttons are similar and only the labels/parameters change. And it would definitely save you the task of having to manually edit each button