I am sharing the below button code just as an example, so that others can follow if interested.
I copied the code from the "[CustomButtons]" section from my XYplorer.ini file after i created the button and subsequent restart.
What does this button do:
Based on this thread http://www.xyplorer.com/xyfc/viewtopic.php?f=5&t=4384, i made a simple script/button. If you left-click on the button you will get normal sort options offered by XY, while if you right-click you will get different sort options which will "Sort Folders Apart" if you sort by Name, Ext, Size or Type but will remove "Sort Folders Apart" option if you sort by Created, Modified or Accessed.
How to use:
Simply copy/paste the below code into Try script or catalog and run it ONLY once. This will first save your settings, then read/write some settings and finally will restart XY. The new button will be last one in the Customize toolbar's "Current buttons" list.
Code: Select all
//Save settings
#182;
//Getkeys
getkey $count, "count", "CustomButtons";
getkey $toolbar, "Toolbar", "General";
//Increment count
incr $count;
//Button code
$button= <<<BUTTONCODE
"Sortby|:sort|0" "XYSort|:sort" button "sort" "Name"¶¶ global $sort;¶¶ $sort=name;¶¶ sub "_eval";¶¶ ¶¶"Ext"¶¶ global $sort;¶¶ $sort=ext;¶¶ sub "_eval";¶¶¶¶"Size"¶¶ global $sort;¶¶ $sort=size;¶¶ sub "_eval";¶¶¶¶"Type"¶¶ global $sort;¶¶ $sort=type;¶¶ sub "_eval";¶¶¶¶"Created"¶¶ global $sort;¶¶ $sort=created;¶¶ sub "_eval";¶¶¶¶"Modified"¶¶ global $sort;¶¶ $sort=modified;¶¶ sub "_eval";¶¶¶¶"Accessed"¶¶ global $sort;¶¶ $sort=accessed;¶¶ sub "_eval";¶¶¶¶¶¶¶¶"eval : _eval"¶¶ global $sort;¶¶ IF ($sort=="name"){¶¶ sub "_nodate";¶¶ }¶¶ ELSEIF ($sort=="ext"){¶¶ sub "_nodate";¶¶ }¶¶ ELSEIF ($sort=="size"){¶¶ sub "_nodate";¶¶ }¶¶ ELSEIF ($sort=="type"){¶¶ sub "_nodate";¶¶ }¶¶ ELSEIF ($sort=="created"){¶¶ sub "_date";¶¶ }¶¶ ELSEIF ($sort=="modified"){¶¶ sub "_date";¶¶ }¶¶ ELSEIF ($sort=="accessed"){¶¶ sub "_date";¶¶ }¶¶ ¶¶"Non-date : _nodate"¶¶ global $sort;¶¶ Settingp SortFoldersApart,1;¶¶ //Settingp KeepFoldersOnTop,1;¶¶ Sortby $sort, clk;¶¶¶¶"Date : _date"¶¶ global $sort;¶¶ Settingp SortFoldersApart,0;¶¶ Sortby $sort,clk;
BUTTONCODE;
//Setkeys
setkey $count, "count", "CustomButtons";
setkey $button, $count, "CustomButtons";
//append button to current buttons list and setkey
$toolbar=$toolbar.",ctb$count";
setkey $toolbar, "Toolbar", "General";
//Restart without saving
#190;
Note however that the code in the Xyplorer.ini file will have extra quotes, remove the first and last quote before pasting it.
Feedback/Comments/Criticisms welcome.
Update: The above code won't work as the forum software removed some spaces. Instead download the file below, Select the file and run it from menu "Scripting | Load selected script file"