Toggle a Configuration Setting Using a Script
-
soldier9599
- Posts: 10
- Joined: 16 May 2014 02:43
Toggle a Configuration Setting Using a Script
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.
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.
-
admin
- Site Admin
- Posts: 64828
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Toggle a Configuration Setting Using a Script
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:
Don
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
FAQ | XY News RSS | XY X
-
PeterH
- Posts: 2826
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: Toggle a Configuration Setting Using a Script
Code: Select all
echo tweak("ContextMenu64", 1); // set on and get previous state? -
admin
- Site Admin
- Posts: 64828
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Toggle a Configuration Setting Using a Script
Yes, and the question is...?
FAQ | XY News RSS | XY X
-
PeterH
- Posts: 2826
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: Toggle a Configuration Setting Using a Script
...will this be possible? (Setting the setting *and* getting the old value.)admin wrote:Yes, and the question is...?
-
admin
- Site Admin
- Posts: 64828
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Toggle a Configuration Setting Using a Script
Yes, it IS possible already now. 
FAQ | XY News RSS | XY X
-
PeterH
- Posts: 2826
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: Toggle a Configuration Setting Using a Script
Then it's no questionadmin wrote:Yes, it IS possible already now.
-
soldier9599
- Posts: 10
- Joined: 16 May 2014 02:43
Re: Toggle a Configuration Setting Using a Script
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:
Here is my right click code:
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", ""); // toggleCode: 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.";
}-
driftingnarwhal
- Posts: 3
- Joined: 03 Jun 2020 00:17
Re: Toggle a Configuration Setting Using a Script
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!
Here's what I'm using as my script to run on left click:
tweak("SortFoldersApart", "");
Thanks for your help!
Last edited by driftingnarwhal on 06 Mar 2022 01:58, edited 1 time in total.
Re: Toggle a Configuration Setting Using a Script
tweak only supports a limited set of commands, what you want to do can be done like this though:
you'll need to add to the script if you want to make it toggle.
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.
-
driftingnarwhal
- Posts: 3
- Joined: 03 Jun 2020 00:17
Re: Toggle a Configuration Setting Using a Script
Okay thank you so much!!
Re: Toggle a Configuration Setting Using a Script
Actually sorry, you can make it a toggle using this command
#333; instead.-
driftingnarwhal
- Posts: 3
- Joined: 03 Jun 2020 00:17
Re: Toggle a Configuration Setting Using a Script
Even better. Thanks again for the help!
Re: Toggle a Configuration Setting Using a Script
I get "Key 'ContextMenu64' is not supported by Tweak". Something changed?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
Re: Toggle a Configuration Setting Using a Script
One of my scripts helped you out? Please donate via Paypal
XYplorer Beta Club