Page 1 of 1

[Q] How to make custom button to toggel configuration settings?

Posted: 16 Dec 2022 18:06
by daniel_m
Hei!

I'd like to have a custom toolbar button that toggles a configuration setting. In particular, I would like to toggle "General > Tree and List > Tree > Check existence of subfolders in tree > In network locations as well".

Is there any way to do that?

Re: [Q] How to make custom button to toggel configuration settings?

Posted: 18 Dec 2022 16:46
by klownboy
There's no "setting" script command or tweak for what you're looking for, but you can achieve it using the sendkeys command. Of course, the Configuration dialog box will flicker a moment since the script is changing a Configuration setting and it's doing it in your face.

Code: Select all

// this script will cycle "In network locations as well" in Configuration > Tree and List regardless of the Check existence of subfolders in tree setting
  sendkeys '{PGUP}%w{ }{ENTER}';#600; // to cycle "In network locations as well"

// this script will cycle "Check existence of subfolders in tree" regardless of the "In network locations as well" setting
  sendkeys '{PGUP}%k{ENTER}';#600; // to cycle "Check existence of subfolders in tree"
You can assign the first one, which I believe is what you are after, to a UDC or CTB.

Re: [Q] How to make custom button to toggel configuration settings?

Posted: 18 Dec 2022 17:13
by daniel_m
I don't need to toggle this setting often, and your sendkeys approach is doing a perfectly fine job.
Thank you so much 💝

Re: [Q] How to make custom button to toggel configuration settings?

Posted: 19 Dec 2022 08:14
by admin
klownboy, could you explain what the script is doing?

Re: [Q] How to make custom button to toggel configuration settings?

Posted: 19 Dec 2022 12:49
by klownboy
It's not doing anything too exciting just sending keystrokes into the Configuration dialog which I've found in the past you have to send or feed before the CID #600 that opens Configuration.
- {PgUp} makes sure we are at the Tree and List in the General section (i.e., the top). I'd use {Home} instead but it does not work properly.
- %w sends the cursor down to the first "w" accelerator, "In network locations as well"
- { } sends a space character to check that setting. {Space} does not work.
- {Enter} is then sent to finalize and close the Configuration dialog.

There was a lot of trial and error took place before I posted this - mostly "Error 5" concerning the use of sendkeys {Home} and {Space}. :)
"%w" would activate the setting as well if there was only one instance of accelerator "w", but you have 2 "w" accelerators in that section, so it only goes to the setting and does not activate or check it. It does in the case of "%k" in the other example since there is only one instance of "k".

Re: [Q] How to make custom button to toggel configuration settings?

Posted: 19 Dec 2022 12:53
by admin
Pretty confusing that you feed the keystrokes before opening the dialog. :mrgreen:

Re: [Q] How to make custom button to toggel configuration settings?

Posted: 19 Dec 2022 14:16
by GreetingsFromPoland
is this a chance for a new scripting command ? maybe togglesetting() ? i am assuming that every configuration setting has a number assigned to it internally. if that is the case you could togglesetting(600); and it would flip the existing setting regardless of what it is set. if checked, uncheck. if unchecked, check.

Re: [Q] How to make custom button to toggel configuration settings?

Posted: 19 Dec 2022 14:19
by admin
Your assumption is true for menu commands but not for settings.

Re: [Q] How to make custom button to toggel configuration settings?

Posted: 19 Dec 2022 14:43
by klownboy
admin wrote: 19 Dec 2022 12:53 Pretty confusing that you feed the keystrokes before opening the dialog. :mrgreen:
Yes, it is a bit odd, but I assume those keystrokes are are being saved in memory to be fed into the Configuration dialog when it opens. It just doesn't work the other way around...too late I guess. I found that out using List Management CIDs as well (e.g., #614, #632, #624.). You have to feed the keystrokes into those dialog boxes before you call the CID.