Page 1 of 2
Toggle a Configuration Setting Using a Script
Posted: 20 May 2014 05:42
by soldier9599
I would like to be able to write scripts that toggle configuration settings, but I can't figure out any syntax relating to this. Specifically, I am currently interested in creating a custom hotkey and toolbar button that toggle between 32 and 64 bit context menus. Is this possible? I have coding experience, but I only started using XYplorer a few days ago so I'm a bit lost. So far I've done a "hello world" and that's it. I have figured out how to make a custom toolbar button run a script and how to set a hotkey to a UDC, but I can't figure out how to edit configuration settings using scripts. Any help would be appreciated.
I realize there is an option to view the 64-bit context menu in the 32-bit context menu, but I'd rather just have a toggle switch if possible. Ideally, I would have one combined context menu with all of the options, but I'm assuming that's not possible, am I right? Also, I'm not looking to alter the XYplorer.ini file. That would just be a change the initialization settings and require restarting the program to take effect. I'm trying to toggle the setting as if I went into configuration and altered the value currently saved into RAM.
Re: Toggle a Configuration Setting Using a Script
Posted: 20 May 2014 06:51
by admin
Hi and welcome!
This is currently not possible, but I think it can be useful, so I will make it accessible via the non-documented tweak() command in the next beta. It will work like this:
Code: Select all
tweak("ContextMenu64", ""); // toggle
tweak("ContextMenu64", 1); // on
tweak("ContextMenu64", 0); // off
echo tweak("ContextMenu64"); // get state
Don
Re: Toggle a Configuration Setting Using a Script
Posted: 20 May 2014 15:37
by PeterH
Code: Select all
echo tweak("ContextMenu64", 1); // set on and get previous state?

Re: Toggle a Configuration Setting Using a Script
Posted: 20 May 2014 15:38
by admin
Yes, and the question is...?
Re: Toggle a Configuration Setting Using a Script
Posted: 20 May 2014 15:51
by PeterH
admin wrote:Yes, and the question is...?
...will this be possible? (Setting the setting *and* getting the old value.)
Re: Toggle a Configuration Setting Using a Script
Posted: 20 May 2014 16:07
by admin
Yes, it IS possible already now.

Re: Toggle a Configuration Setting Using a Script
Posted: 20 May 2014 16:09
by PeterH
admin wrote:Yes, it IS possible already now.

Then it's no question

Re: Toggle a Configuration Setting Using a Script
Posted: 20 May 2014 20:03
by soldier9599
Thanks! This is perfect.
I worked with it a bit to make it so on left click my button would toggle, and on right click it would allow me to choose the state or check the state with easy to understand English language text.
My left click code is just the toggle state line you have:
Code: Select all
tweak("ContextMenu64", ""); // toggle
Here is my right click code:
Code: Select all
"Enable 64-bit Menu"
tweak("ContextMenu64", 1); // on
"Enable 32-bit Menu"
tweak("ContextMenu64", 0); // off
"Check State"
if (tweak("ContextMenu64") == 0) {
echo "32-bit menus are activated.";
}
elseif (tweak("ContextMenu64") == 1) {
echo "64-bit menus are activated.";
}
Re: Toggle a Configuration Setting Using a Script
Posted: 06 Mar 2022 01:57
by driftingnarwhal
Hello I'm trying to use the tweak command to make a toggle to set whether folders are sorted separately or not, but I'm getting an error that SortFoldersApart is not supported by tweak. Is there a reason that it's not supported?
Here's what I'm using as my script to run on left click:
tweak("SortFoldersApart", "");
Thanks for your help!
Re: Toggle a Configuration Setting Using a Script
Posted: 06 Mar 2022 02:01
by jupe
tweak only supports a limited set of commands, what you want to do can be done like this though:
settingp "SortFoldersApart", 1; and to turn off settingp "SortFoldersApart", 0;
you'll need to add to the script if you want to make it toggle.
Re: Toggle a Configuration Setting Using a Script
Posted: 06 Mar 2022 02:08
by driftingnarwhal
Okay thank you so much!!
Re: Toggle a Configuration Setting Using a Script
Posted: 06 Mar 2022 02:09
by jupe
Actually sorry, you can make it a toggle using this command #333; instead.
Re: Toggle a Configuration Setting Using a Script
Posted: 06 Mar 2022 02:10
by driftingnarwhal
Even better. Thanks again for the help!
Re: Toggle a Configuration Setting Using a Script
Posted: 06 Mar 2022 12:13
by xy123
soldier9599 wrote: ↑20 May 2014 20:03
My left click code is just the toggle state line you have:
Code: Select all
tweak("ContextMenu64", ""); // toggle
I get "Key 'ContextMenu64' is not supported by Tweak". Something changed?
jupe wrote: ↑06 Mar 2022 02:01
tweak only supports a limited set of commands
Re: Toggle a Configuration Setting Using a Script
Posted: 06 Mar 2022 12:29
by highend