ExpandDriveButton v2.4 Changelog:
v2.4-
1. Certain title templates caused second instance of XY to open.
Added /hwnd=<hwnd> switch which was added in v13.10.0137.
v2.3-
1. Two missing commas were causing problems. Fixed.
v2.2-
1. Fixed #2 for the bug from v2.1
v2.1-
1. Fixed a small bug where ctbindex 1 could not be differentiated from 10
v2-
1. Added 3 ways to collapse button:
- a. Manual (toggle to collapse/expand drive)
b. Auto (auto-collapse when clicking on list) - DEFAULT
c. Timed (Close after x seconds)
2. Configurable icons for Collapse and Expand
3. Fixed a bug where creating a new button was ignored on next session start
4. Added unset to remove most permanent variables
v1.5-
1. Removed <get trigger ctbindex>, instead the script has to be run from script file to allow auto-close ctb feature.
2. Added the auto-close ctb feature with 5 seconds set as default.
3. Uses run command to initiate script label "_Autoclose" from outside, therefore allowing full control of clicks inside XY
Thanks to Ken, to help me get rid of the black DOS window!
v1-
1. First release: Expand Drive Button adds drive button to it's right
2. Use of new <get trigger ctbindex> to get button index and expand button
Note: This script uses permanent variable to make it work across sessions, so in menu Tools|Configuration enable: Remember permanent variables (Refresh, Icons, History - Scripting)
Code: Select all
//Expandable Drive Button -v2.4
/*This script expands the Custom Toolbar Button (CTB) to show button fixed drives to it's right.
The CTB can be collapsed manually or automatically (see settings)
How to use it:
1) Save the script as XY script file and put it in XY's script folder.
2) Make a new CTB and note it's index and change it in the script below.
3) Enter load "ExpandDriveButton.xys"; in the CTB's "On click:" field.
*/
perm $p_ctbindex, $p_officon, $p_onicon;
//Settings (tagged with ###)
//###
//(1) CTB index: change the below "$p_ctbindex" to the index of your ctb
$p_ctbindex="18";
//###
//(2) Autocollapse options: change $collapse to one of the following-
// a) 0 = Manual collapse
// b) -1 = Default: Auto-collapse button when clicking on list (or catalog or addressbar)
// c) Any positive number = seconds to wait before collapsing button
$collapse=-1;
//###
//(3) CTB icons: use either in-built XY icon (":drives")or your own (eg:"drive.ico")
$p_officon=":drives"; //collapsed icon
$p_onicon=":drives"; //expanded icon
$curctb="ctb$p_ctbindex";
$toolbar=toolbar();
if (ctbstate(,$p_ctbindex) == 0) {
sub "_PVCheck";
perm $p_toolbar;
$p_toolbar=$toolbar;
if(ctbicon(,$p_ctbindex)==""){
ctbicon("$p_officon",$p_ctbindex);
}
ctbicon("$p_onicon",$p_ctbindex);
ctbstate(1,$p_ctbindex);
$newtoolbar=replace($toolbar,"$curctb,","$curctb,{drives_fix},-,") ;
toolbar($newtoolbar);
if($collapse=="0") {
end(1==1);
}
elseif($collapse=="-1"){
run "cmd /c cd /d <xypath> & xyplorer.exe /script=""::load 'ExpandDriveButton.xys','_AutoCollapse'"" /flg=2 /hwnd=<hwnd>", , 0,0;
end(1==1);
}
else{
run "cmd /c ping -n $collapse 127.0.0.1 >nul & cd /d <xypath> & xyplorer.exe /script=""::load 'ExpandDriveButton.xys','_WaitCollapse'"" /flg=2 /hwnd=<hwnd>", , 0,0;
}
}
else {
ctbicon("$p_officon",$p_ctbindex);
ctbstate(0,$p_ctbindex);
$oldtoolbar=replace($toolbar,"$curctb,{drives_fix},-,","$curctb,");
toolbar($oldtoolbar);
unset $p_ctbindex, $p_officon, $p_onicon;
end(1==1);
}
"_PVCheck"
$PV_ON=getkey("ScriptRetainPVs", "Settings");
if($PV_ON==1){
//nothing
}
else{
$confirm= confirm ("To make this script work accross sessions, please check: <br>'Remember Permanent Variables' from <br>Tools | Configuration| Refresh, Icons, History - Scripting <br>Go to configuration now? <br>OK=Yes Cancel=No");
if ($confirm==1){
#600;
savesettings;
}
}
"_WaitCollapse"
ctbicon("$p_officon",$p_ctbindex);
ctbstate(0,$p_ctbindex);
toolbar($p_toolbar);
unset $p_ctbindex, $p_officon, $p_onicon;
"_AutoCollapse"
focus "T";
while("<get FocusedControl>"=="T"){
wait(100);
//Stay in loop if focus is on address bar
//Break out of loop if focus on list, tree or catalog
}
ctbicon("$p_officon",$p_ctbindex);
ctbstate(0,$p_ctbindex);
toolbar($p_toolbar);
unset $p_ctbindex, $p_officon, $p_onicon;