(CTB=Customized Toolbar Button => user editable buttons)
With this script you can save the current toolbar-icons-setting to an file.
Then you can modify the toolbar by adding or removing icons for other working issues.
Later you can load the last setting or reset the toolbar to factory default.
Note that the scripts behind the CTB-Icons are stored in the XYplorer.ini.
Use "Read User Button..." to get the wanted script (copy and save them if you need)
ToolbarManager.xys Version 003 - (find a updated version below this code)
Code: Select all
// Version 001
// 11:56 Dienstag, 31. Mai 2011
// Version 002
// 07:45 01.06.2011
// convert to store settings to ini instead of single files
// Version 003
// 12:51 Samstag, 7. Januar 2012
// clean up the code
/*
How to use:
1.) Add an new CTB and add this script to it.
2.) Save XY config via "File > Settings" to store this settings in XY ini.
3.) Execute "Save current toolbar" to store the current toolbar in user.ini.
-
4.) Modify the toolbar to suit your needs. Don't forget to add/leave an CTB with this script too.
5.) Save XY config via "File > Settings" to store this settings in XY ini.
6.) Execute "Save current toolbar" to store the current toolbar in user.ini.
-
7.) Go to 4.)
-
8.) Execute "Load saved toolbar..." to load one of the saved toolbars.
*/
"=== Toolbar Manager ==="
"Save current toolbar..."
$myINIFile = "<xydata>\User.ini";
$SectionCount = getkey( "Count", "Toolbars", $myINIFile);
if ($SectionCount == 20)
{
$iter=1;
while($iter<$SectionCount)
{
$iter++;
if (strlen($iter)==1){$iter = "0$iter";}
$Date = getkey( $iter . "_Date", "Toolbars", $myINIFile);
$Name = getkey( $iter . "_Name", "Toolbars", $myINIFile);
$Valu = getkey( $iter . "_Valu", "Toolbars", $myINIFile);
//---
$iter--;
if (strlen($iter)==1){$iter = "0$iter";}
setkey($Date, $iter . "_Date", "Toolbars", $myINIFile);
setkey($Comm, $iter . "_Name", "Toolbars", $myINIFile);
setkey($Icon, $iter . "_Valu", "Toolbars", $myINIFile);
//---
$iter++;
}
$SectionCount--;
}
$SectionCount++;
if (strlen($SectionCount)==1){$SectionCount = "0$SectionCount";}
$Date = "<date yyyy.mm.dd hh:nn> on %ComputerName%";
$curTB = toolbar();
$Name = Input("Save Toolbar", "Enter an NAME (or comment) for this toolbar (optional)",,"s","");
If ($Name=="") {$Name="-";}
//setkey value, key, section, [INIfile]
setkey($SectionCount, "count", "Toolbars", $myINIFile);
setkey($Date, $SectionCount . "_Date", "Toolbars", $myINIFile);
setkey($Name, $SectionCount . "_Name", "Toolbars", $myINIFile);
setkey($curTB, $SectionCount . "_Valu", "Toolbars", $myINIFile);
"Load saved toolbar..."
$myINIFile = "<xydata>\User.ini";
$iter=1;
$SectionCount = getkey( "Count", "Toolbars", $myINIFile);
$array="";
while($iter <= $SectionCount)
{
if (strlen($iter)==1){$iter = "0$iter";}
$Date = getkey( $iter . "_Date", "Toolbars", $myINIFile);
$Name = getkey( $iter . "_Name", "Toolbars", $myINIFile);
$Valu = getkey( $iter . "_Valu", "Toolbars", $myINIFile);
$array = $array . "$iter; $Date; $Name; $Valu|";
$iter++;
}
$newTB = inputselect("Select ONE stored toolbar to load as current:",$array,,2);
end ($newTB==""); // IF [OK] without selection==Quit, or [Cancel]==Quit
$newTB = gettoken($newTB, 1, ";");
$newTB = getkey( $newTB . "_Valu", "Toolbars", $myINIFile);
$TBsize = confirm("OK: <tab>big icons<crlf>Cancel: <tab>small icons") ? 1 : 0;
toolbar("$newTB", $TBsize);
//msg "Done. Go and save XYplorer settings via File > Settings > Save";
################# U P D A T E
I had an try, please see if this will work:aurumdigitus wrote:Suppose an already saved TB has had several button changes made and those changes are to be kept.
When clicking Save Current Toolbar the dialog box shows the value for $DefaultDescription.
What it ought to show is the name of the current TB (assuming it was already saved) OR $DefaultDescription.
Then the user could replace the original with an overwrite or save under a new name.
Maybe the Menu should have a Save As command which is a standard in Windows.
03 Apr 2013
- use "Save as..." to save as new TB
- use "Update..." to Update a saved TB
I see there no way right now.aurumdigitus wrote:Is there anyway XY could display the name of the one currently in use?
But since you work with TBs you can maybe add an icon
which represents the current used TB to each TB to load this script?
e.g. the icon on ToolBar1 could show a "TB 1" icon to load this script,
and the icon on ToolBar2 could show a "TB 2" icon to load this script,...
For the moment you can utilize "Update TB..." to see which TB is currently loaded.
ToolbarManager.xys Version 006 aurumdigitus edition
I still want to clean up the whole code and change variable names.... its a mess now.
Well, if I find some time on winter season ;-)
Code: Select all
//http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=6538&p=72090
//http://www.xyplorer.com/xyfc/viewtopic.php?p=67359#p67359
// Version 001 // 11:56 Dienstag, 31. Mai 2011
// Version 002 // 07:45 01.06.2011 // convert to store settings to ini instead of single files
// Version 003 // 12:51 Samstag, 7. Januar 2012 // clean up the code
// version 004 // 20:49 Freitag, 27. Januar 2012 ++ 25.03.2013 22:47 for aurumdigitus
// "Delete saved toolbar..." which would invoke:"Select one or more stored toolbar(s) to DELETE:"
// >>see > http://www.xyplorer.com/xyfc/viewtopic.php?f=5&t=7436&p=67549&hilit=toolbar+manager#p67549
// version 005 // 28.03.2013 23:38 // cleaned up the code
// version 006 // 03.04.2013 19:15 // added "Update current toolbar..."
"=== Toolbar Manager ==="
"_INIT"
//// USER SETTINGS - Common settings for all scripts below:
global $TBINIFile, $DateFormat, $DefaultDescription, $SectionName, $DateName, $NameName, $ValuName;
global $ShowMessageAfterAction, $BackupIniBeforeDelete, $OpenIniAfterAction;
// ---------------------------------------------------
//Set ini file to store Toolbars:
$TBINIFile = "<xydata>\User.ini";
//Use your own descriptions for Section and value lines:
$SectionName = "Toolbars"; //name of the section of the ini
$DateName = "_Date"; //name of the line with the date of saving
$NameName = "_Name"; //name of the line with the name or description of the saving
$ValuName = "_Valu"; //name of the line with the value (the toolbar items)
//Set format of date, time and hostname for saved toolbar:
$DateFormat = "<date yyyy.mm.dd hh:nn> on %ComputerName% as %UserName%";
//Set default description for saved toolbar:
$DefaultDescription = "-";
// ---------------------------------------------------
//Show message box after action: True/False
$ShowMessageAfterAction = true;
//Backup ini file before deleting items (debug mode): True/False
$BackupIniBeforeDelete = True;
//Open ini file after action (debug mode): True/False
$OpenIniAfterAction = TRUE;
// ---------------------------------------------------
//// ==================================================================================
//// ==================================================================================
//// ==================================================================================
//// THE CODE, DO NOT TOUCH if you do not know how
"Save as..."
load "*", "_INIT";
global $TBINIFile, $DateFormat, $DefaultDescription, $SectionName, $DateName, $NameName, $ValuName;
global $ShowMessageAfterAction, $BackupIniBeforeDelete, $OpenIniAfterAction;
$CurrentUsedTBNumb = getkey("CurrentlyUsedIndex", $SectionName, $TBINIFile);
if($CurrentUsedTBNumb==""){
$CurrentUsedTBName=$DefaultDescription;
}else{
$CurrentUsedTBName = getkey($CurrentUsedTBNumb . $NameName, $SectionName, $TBINIFile);
}
$SectionCount = getkey("Count", $SectionName, $TBINIFile);
$SectionCount++;
if(strlen($SectionCount)==1){$SectionCount = "0$SectionCount";}
$Date = $DateFormat;
$Name = Input("Save as new Toolbar", "Enter an description for this toolbar (optional)",$CurrentUsedTBName,"s","UserCancelled");
end($Name=="UserCancelled"); // IF [OK] without selection==Quit, or [Cancel]==Quit
//some value is mandatory!!!, otherwise the whole line is not written
if($Name==""){$Name="-";}
$Valu = toolbar();
$index = $SectionCount;
setkey $SectionCount, "Count" , $SectionName, $TBINIFile,2;
setkey $index ,"CurrentlyUsedIndex", $SectionName, $TBINIFile,2;
setkey $Date , $index . $DateName, $SectionName, $TBINIFile,2;
setkey $Name , $index . $NameName, $SectionName, $TBINIFile,2;
setkey $Valu , $index . $ValuName, $SectionName, $TBINIFile,2;
if($OpenIniAfterAction){run notepad $TBINIFile;}
"Update..."
load "*", "_INIT";
global $TBINIFile, $DateFormat, $DefaultDescription, $SectionName, $DateName, $NameName, $ValuName;
global $ShowMessageAfterAction, $BackupIniBeforeDelete, $OpenIniAfterAction;
$CurrentUsedTBNumb = getkey("CurrentlyUsedIndex", $SectionName, $TBINIFile);
if($CurrentUsedTBNumb==""){
$CurrentUsedTBName=$DefaultDescription;
}else{
$CurrentUsedTBName = getkey($CurrentUsedTBNumb . $NameName, $SectionName, $TBINIFile);
}
if(strlen($CurrentUsedTBNumb)==1){$CurrentUsedTBNumb = "0$SectionCount";}
$Date = $DateFormat;
$Topic = "Update Toolbar $CurrentUsedTBNumb, $CurrentUsedTBName";
$Notes = "Timestamp and value will be updated, you may want to modify the description too?";
$Name = Input($Topic, $Notes,$CurrentUsedTBName,"s","UserCancelled");
end($Name=="UserCancelled"); // IF [OK] without selection==Quit, or [Cancel]==Quit
//some value is mandatory!!!, otherwise the whole line is not written
if($Name==""){$Name="-";}
$Valu = getkey($CurrentUsedTBNumb . $ValuName , $SectionName, $TBINIFile);
$index = $CurrentUsedTBNumb;
setkey $index ,"CurrentlyUsedIndex", $SectionName, $TBINIFile,2;
setkey $Date , $index . $DateName, $SectionName, $TBINIFile,2;
setkey $Name , $index . $NameName, $SectionName, $TBINIFile,2;
setkey $Valu , $index . $ValuName, $SectionName, $TBINIFile,2;
if($OpenIniAfterAction){run notepad $TBINIFile;}
"Load..."
load "*", "_INIT";
global $TBINIFile, $SectionName, $DateName, $NameName, $ValuName;
global $ShowMessageAfterAction, $BackupIniBeforeDelete, $OpenIniAfterAction;
end( exists($TBINIFile)==0), "The set ini file is not found:<crlf 2> $TBINIFile" ;
//-----------------Load Section:
$SectionCount = getkey("Count", $SectionName, $TBINIFile);
$loop = 1;
$SectionList = "";
while($loop <= $SectionCount){
if (strlen($loop)==1){$loop = "0$loop";}
$Date = getkey($loop . $DateName, $SectionName, $TBINIFile);
$Name = getkey($loop . $NameName, $SectionName, $TBINIFile);
$Valu = getkey($loop . $ValuName, $SectionName, $TBINIFile);
$SectionList = $SectionList . "$loop;$Date;$Name;$Valu|";
$loop++;
}
$WantedTB = inputselect("Select ONE stored toolbar to load as current:",$SectionList,,2);
end ($WantedTB==""); // IF [OK] without selection==Quit, or [Cancel]==Quit
$WantedTB = gettoken($WantedTB, 1, ";");
setkey $WantedTB, "CurrentlyUsedIndex", $SectionName, $TBINIFile,2;
$WantedTB = getkey($WantedTB . $ValuName, $SectionName, $TBINIFile);
$TBsize = confirm("Icon size?<crlf 2>OK: <tab>big icons<crlf>Cancel: <tab>small icons") ? 1 : 0;
toolbar("$WantedTB", $TBsize);
if($ShowMessageAfterAction){msg "Done. To keep this toolbar, be sure to save XYplorer settings.";}
"Delete..."
load "*", "_INIT";
global $TBINIFile, $SectionName, $DateName, $NameName, $ValuName;
global $ShowMessageAfterAction, $BackupIniBeforeDelete, $OpenIniAfterAction;
end(exists($TBINIFile)==0), "The set ini file is not found:<crlf 2> $TBINIFile" ;
//-----------------Load Section:
$SectionCount = getkey( "Count", $SectionName, $TBINIFile);
end($SectionCount < 1),"No items found in ini file:<crlf 2>$TBINIFile";
$loop = 1;
$SectionList = "";
while($loop <= $SectionCount){
if (strlen($loop)==1){$loop = "0$loop";}
$Date = getkey($loop . $DateName, $SectionName, $TBINIFile);
$Name = getkey($loop . $NameName, $SectionName, $TBINIFile);
$Valu = getkey($loop . $ValuName, $SectionName, $TBINIFile);
$SectionList = $SectionList . "$loop;$Date;$Name;$Valu|";
$loop++;
}
//-----------------Ask User which entry to delete:
$DeleteList = inputselect("Select one or more stored toolbar(s) to DELETE:",$SectionList,,2);//"|"
end($DeleteList==""); // IF [OK] without selection==Quit, or [Cancel]==Quit
$DeleteCount = gettoken($DeleteList, "count", "|");
//-----------------Get list of indices to delete
$UserConfirmList = "";
$DeleteIndexList = "";
$loop = 1;
while($loop <= $DeleteCount){
$currLine = gettoken($DeleteList,$loop,"|");
$pos = 0; $pos = strpos($currLine,";", $pos)+1;
$DeleteIndexList = $DeleteIndexList . substr($currLine,0 ,$pos) . "|";
$pos = strpos($currLine,";", $pos)+1;
$pos = strpos($currLine,";", $pos)+1;
$out = substr($currLine,0, $pos);
$UserConfirmList = $UserConfirmList . $out . "<crlf>";
$loop++;
}
//-----------------Let User confirm selected entries (last change to cancel):
msg "OK, we will delete now $DeleteCount toolbars:<crlf>$UserConfirmList",1;
if($BackupIniBeforeDelete){copyitem $TBINIFile; //automatically backup current ini}
//-----------------Write entries to keep back to section but with new index
$loop = 1;
$newIndex = 0;
while($loop <= $SectionCount){
$currLine = gettoken($SectionList, $loop, "|");
$currIndex = substr($currLine,0 ,2);
if(strpos($DeleteIndexList,$currIndex) == -1){
//current line index is not in IndexList, so keep this line
$Date = gettoken($currLine, 2, ";");
$Comm = gettoken($currLine, 3, ";");
$Icon = gettoken($currLine, 4, ";");
$newIndex++;
if (strlen($newIndex)==1){$newIndex = "0$newIndex";}
setkey $Date, $newIndex . $DateName, $SectionName, $TBINIFile,2;
setkey $Comm, $newIndex . $NameName, $SectionName, $TBINIFile,2;
setkey $Icon, $newIndex . $ValuName, $SectionName, $TBINIFile,2;
}
$loop++;
}
setkey $newIndex, "Count", $SectionName, $TBINIFile,2;
//-----------------Delete remaining, no more needed lines from section
while($newIndex <= $SectionCount){
$newIndex++;
if(strlen($newIndex)==1){$newIndex = "0$newIndex";}
setkey "", $newIndex . $DateName, $SectionName, $TBINIFile,2;
setkey "", $newIndex . $NameName, $SectionName, $TBINIFile,2;
setkey "", $newIndex . $ValuName, $SectionName, $TBINIFile,2;
}
if($ShowMessageAfterAction){msg "Done. $DeleteCount toolbars deleted.";}
if($OpenIniAfterAction){run notepad $TBINIFile;}
-
"Cancel"
-
"Edit this &script"
self $ScriptFile, file;
OpenWith "<xypath>\Tools\NotePad2\Notepad2.exe", ,$ScriptFile;
//OpenWith "Notepad", ,$ScriptFile;
//EOF
Right click the tool bar and choose "Customize Toolbar..."
Then add an free "User Button #nn" and customize it like this:
-
Notes:
you don't have to modify anything, just save the script to an *.xys file and load it from XYplorer.
But you can modify if you want this settings:
$myINIFile = "<xydata>\User.ini"; //the file to store the settings. You may want to edit this to "toolbars.ini" for example.
$Date = "<date yyyy.mm.dd hh:nn> %ComputerName%"; //add or remove parts of info as you like.
EDIT: add a few more infos what's about.
.