Expandable drive button

Discuss and share scripts and script files...
CookieMonster

Re: Expandable drive button

Post by CookieMonster »

It would be nice if you could customize the button to include whatever you want ?

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: Expandable drive button

Post by klownboy »

Actually you can. Please refer this post within this thread... http://www.xyplorer.com/xyfc/viewtopic. ... =30#p92968
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

CookieMonster

Re: Expandable drive button

Post by CookieMonster »

klownboy wrote:Actually you can. Please refer this post within this thread... http://www.xyplorer.com/xyfc/viewtopic. ... =30#p92968
Hi, sorry I don't quite understand my scripting in XY is still weak :( :)

edyyus
Posts: 48
Joined: 16 May 2014 11:14

Re: Expandable drive button

Post by edyyus »

Code: Select all

 $newtoolbar=replace($toolbar,"$curctb,","$curctb,{drives_fix},-,") ;  
Thanks for great script :mrgreen:

but must remove one " , " in the cript,
with " , " you can get blank button in customize Toolbar

Code: Select all

 $newtoolbar=replace($toolbar,"$curctb,","$curctb,{drives_fix},-") ;  

edyyus
Posts: 48
Joined: 16 May 2014 11:14

Re: Expandable drive button

Post by edyyus »

Sample script, i use for Expand button and opened from left user button "ctb15"

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 "ExpandButton.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 ctb10 to ctb3+
        $p_ctbindex="15";
        
//###
//(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=0;                       
        
//### 
//(3) CTB icons: use either in-built XY icon (":drives")or your own (eg:"drive.ico")
        $p_officon=":tabsets";  //collapsed icon :visualfilter
        $p_onicon=":tabsets";  //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","tsf,visualfilter,ctb31,cofi,icf,showfolders,rename,$curctb") ;
                toolbar($newtoolbar);
                      if($collapse=="0") {
                         end(1==1);
                        }
                      elseif($collapse=="-1"){
                             run "cmd /c cd /d <xypath> & xyplorer.exe /script=""::load 'ExpandButton.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 'ExpandButton.xys','_WaitCollapse'"" /flg=2 /hwnd=<hwnd>", , 0,0; 
                           }                      
               }              
               
          else {
                ctbicon("$p_officon",$p_ctbindex);
                ctbstate(0,$p_ctbindex);
                $oldtoolbar=replace($toolbar,"tsf,visualfilter,ctb31,cofi,icf,showfolders,rename,$curctb,","$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;



klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: Expandable drive button

Post by klownboy »

Your reason for the change may be due to the location first set of quotes: "$curctb," vs. "$curctb",
On my system this works fine.

Code: Select all

$newtoolbar=replace($toolbar,"$curctb","$curctb,$added_CTBs,-,");  toolbar($newtoolbar);
I even have serendipty's nice script modified such that a left click brings on one set of expanding buttons and right click brings up a different set of buttons. I agree, it's a very nice script...almost like a drop down menu but to the right. :D
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: Expandable drive button

Post by klownboy »

This script, ExpandableCTB.xys [v1.0] uses the technique brought to us by serendipity in ExpandDriveButton. Instead of using expanding drives, the user can have various CTBs, either custom buttons or built-in XY buttons. I've had this script working and have been using it since serendipity wrote the script around a year ago. In the past week I've modified and hopefully improved upon it, to have the script obtain the needed information (i.e., CTB index, the user's expanded CTBs, and the collapse method) and also discussed posting it with serendipity. Thank you serendipity. Also thanks to both TheQwerty, a portion was derived from EditUserButton.xys and highend for script self-modification code.

The modifications from serendipity's original include:
1) Expand using any CTBs from a selectable list on first run
2) Use different "expanding" CTBs for left and right click of the mouse,
3) Obtain the CTB index instead of having to provide it in script on first run
4) Also, on first run the user will also chose the method of collapsing the "expanded" CTBs discussed below
5) Enable reset capability - if you drag a file/folder onto the CTB, it will reset the configuration back to the original script, so you can pick different CTBs - nothing is done with the file/folder.

The only thing you have to (or can) modify in the script itself is the icons assigned to left and right click, one each for expanded and collapsed - see comments flagged with ###. I've included some icons in the zip including the ones in the gif. Obviously it makes sense to use icons that signify expanded and collapsed conditions.

How to use it:
1) Place the script in XY's script folder.
2) Make a new CTB, and provide a name (ExpandableCTB or whatever) - must have a name for script to determine CTB index.
3) Enter load "ExpandableCTB.xys"; in the CTB's "On left click" and "On-right click:" fields
4) Place the APPLE, APPLE_HALF, LIGHTHOUSE_SHINE, LIGHTHOUSE_NO_SHINE ico files provided in your <xyicons> folder. You can always change them later.
5) On first run it will, 1) determine the CTB index 2) have you select a expanding CTBs for both Left and right click, 3) and select the collapsing option
The CTBs can be collapsed manually or automatically (see settings).
Collapse options:
Set the collapse value to:
Manual collapse '0' - clicking the CTB again will collapse the CTBs
Auto-collapse '-1' - click anywhere in XY other than the tree or menu bar will collapse the CTBs
Timed collapse 'Any positive number' - will collapse the expanded CTBs in that number of seconds
LeftandRightClicksofExpCTB.gif
LeftandRightClicksofExpCTB.gif (26.41 KiB) Viewed 3780 times
I look at this script as a sub-menu of sorts, instead of dropping down, it expands outward. I hope you enjoy. Please let me know if you have issues. As always though, please do a back up of XYplorer.ini just in case. If you try this on another computer, please use a fresh copy either from the original download or one that's been reset. Thanks.
Ken
ExpandableCTB_v1.0.zip
(19.91 KiB) Downloaded 174 times
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

eil
Posts: 1617
Joined: 13 Jan 2011 19:44

Re: Expandable drive button

Post by eil »

@klownboy, i like your variant as it's more user-friendly. yet i maybe found a bug: when selecting what buttons to use it doesn't show a variant with "Removable Drives(Group)"(all other except this).
Win 7 SP1 x64 100% 1366x768

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: Expandable drive button

Post by klownboy »

Thanks eil for pointing that out. Actually since the script is a bit old, there were quite a few new toolbar buttons also not in the listing like Ghost Filter [ghost], Set Visual Filter [vfset], Set Global Visual Filter [gvfset], Toggle Global Visual Filter [gvf] and Toggle Quick Search [qnstgl] and probably more that I haven't found yet. I had a version 1.01 on my computer but never uploaded it to the forum. I can't even recall what I had changed in v1.01, but I'll update that script with the new buttons. I think the one you mentioned was just flat out missed. If you think of any others let me know. I don't believe there was a automated way to get the listing of the internal XY buttons so I had to generate my own list. Thanks again.

There have been numerous changes in XYplorer for options on clicking/triggering a CTB. So when I get a chance and some ambition, I'll update this script in an additional revision. Like for example, I had to resort to using drag and drop on to the CTB to trigger a reset , now I could simply have the user have the ctrl/shift buttons held down when he clicks the CTB. Or I could have a set of additional buttons expand out when the shift button is held down when clicking the CTB.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

eil
Posts: 1617
Joined: 13 Jan 2011 19:44

Re: Expandable drive button

Post by eil »

klownboy wrote:There have been numerous changes in XYplorer for options on clicking/triggering a CTB. So when I get a chance and some ambition, I'll update this script in an additional revision. Like for example, I had to resort to using drag and drop on to the CTB to trigger a reset , now I could simply have the user have the ctrl/shift buttons held down when he clicks the CTB. Or I could have a set of additional buttons expand out when the shift button is held down when clicking the CTB.
that's real interesting!
btw, can this changes make it possible to modify default "click behavior"? i mean i wanted to use your script to make a button, that expands into removable drives(kinda solution to that my other thread question). and one more problem left - clicking on those appearing drive-buttons opens location in current tab which is not desirable./ can this be "shifted" somehow with changes you mentioned?
anyways i'm looking forward to you update anyways, you variant is interesting by itself, with all the "set it on first run". :wink:
Win 7 SP1 x64 100% 1366x768

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: Expandable drive button

Post by klownboy »

Hi eil, I just tried adding removable drives as one of the expanding buttons and it seems to work fine on my new update. When I click on the button a new tab doesn't open, the drive opens in my tab set as the default. Do you have a default tab? Having a tab set as a default is a nice way to go. All my other tabs I use are locked or locked home zone. This way anywhere you visit will be in the default tab unless you visit a folder location which has a tab of its own. When I did not have a default tab established as you said, when I click on the Removable Drives button it used the current tab if the current tab was unlocked, otherwise it made a new tab.

Honestly, I never used the Removable Drive button until now. I never realized it doesn't even appear unless you have a removable drive on-line which is nice. I mention that only because when used a "Removable Drives" as one of the expanding buttons it doesn't show when expanding when no removable drives are present (i.e., so if I have normally 3 add-on buttons expanding, if a removable drive isn't on-line only 2 show up). In my other script that I mentioned in the other thread, I can control whether a new tab is made or not but for this script since it's an XY- built-in button I don't believe I could change the default action when you click the Removable Drive button.

Edit: You can force the drive to open in a new tab by simply having the shift down when you click on the button as it does when you click in the tree. It will then open the Removable Drive in a new tab regardless if you have a default tab setup or even if you have another tab for the location.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

eil
Posts: 1617
Joined: 13 Jan 2011 19:44

Re: Expandable drive button

Post by eil »

anyways, i'll be waiting for your update. maybe ill just add new tab command when expanding.
Win 7 SP1 x64 100% 1366x768

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: Expandable drive button

Post by klownboy »

Hi folks, I'm posting an update to the ExpandableCTB script - version 1.01. It corrects a few issues I noticed quite sometime ago. It also updates the toolbar buttons choices to include new ones that Don has made since 2014, when I issued the last change. And lastly, to reset the script and assign new buttons, previously the user had to drag a file or folder onto the CTB to initiate a reset. Now, since Don has added new features, the reset will be initiated if the user holds down the "shift" key when they click on the CTB button. If you do this unintentionally, you can cancel out at the reset prompt. Thanks.
ExpandableCTB_v1.01.zip
(20.17 KiB) Downloaded 143 times
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

eil
Posts: 1617
Joined: 13 Jan 2011 19:44

Re: Expandable drive button

Post by eil »

@klownboy, today experienced a huge danger from sideway of how script works.
while using XY last time i pushed button and left it open, next day on XY start it said some files are corrupted(no idea why, but i already had few settings loss dew to this). later i noticed my User > Manage Commands is empty of my commands, but i didn't think loss went further!= when i tried to push button again to close it, it used data from variable which apparently got flushed too, and i've got totally empty toolbar. for my luck Autobackup folder had an .ini with old toolbar present. still it kinda frightened me. =[
i think either save in some txt/ini/script itself is needed or at least check for if variable is not empty.
Win 7 SP1 x64 100% 1366x768

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: Expandable drive button

Post by klownboy »

Sorry you experienced an issue. I'm not sure what happened on your end, but I don't see how using this script could result in corrupted files of any kind. I'll check through the script, but I know I didn't change anything on this recent update that would cause it. I've been using the script since November 2014 with collapse set as either 'autocollapse' or 'timed collapse' with no issues. Just so I know, what was you collapse value set at?

To test, I tried to make it fail by leaving it in the expanded state when I exited XY and it always came back no matter what option I was using. At worse it should only leave the toolbar in an expanded state. I also tried saving and not saving in the expanded state and then exiting. I don't want to save the toolbar variable as permanent cause it's rather long. I'll think about providing an option to save the contents of the SC toolbar() in a text file that can be loaded. I do that in another script which loads, replaces and saves complete toolbars LayCatTools http://www.xyplorer.com/xyfc/viewtopic. ... ls#p107403
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Post Reply