Expandable drive button

Discuss and share scripts and script files...
klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Expandable drive button

Post by klownboy »

Hi serendipity, I like your new version 2. I went to bed last night thinking the original version, that wasn't timed, is still worthwhile, and I woke up and saw that you've incorporated the best of both, timed and manual collapse.

I have your new version working with a left or right click which would add different CTBs. Something like this in the beginning...

Code: Select all

 if (<get trigger> == 1) {
   $added_CTBs = "ctb10,ctb14,ctb15"; }
 if (<get trigger> == 2) {
   $added_CTBs = "cks,cfi,cbx"; }
and then I use the "$added_CTBs" variable later to establish $newtoolbar.

One item I was wondering about even before you posted version 2 though has nothing to do with left or right click, it has to do with $curctb and if you have a timed collapse, where $collapse is either -1 or any positive number, the variable $curctb really doesn't need to be on the new toolbar, only the new additions have to be there (i.e., why would you need $curctb in the timed state because you know if you don't do anything it's going away in "x" number of second anyway). On the other hand if you have $collapse set to "0" for a manual collapse it is absolutely necessary. So I added something like this...

Code: Select all

               if ($collapse == "0") {
               $newtoolbar=replace($toolbar,"$curctb","$curctb,$added_CTBs,-") ; }
               else {$newtoolbar=replace($toolbar,"$curctb","$added_CTBs,-") ; }
I'm still working on the CTBstates though between left and right click so I'm not adding the right click CTBs in $added_CTBs and then adding the left click CTBs cumulatively. It's getting a little hairy... :)

I suppose if we wanted to get really fancy and stick with just a left click as you have it, you could have the right click bring up a edit menu with a listing of the CTBs and select which ones you want to add. Thanks again for the script. It will become very handy.
Ken

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Expandable drive button

Post by serendipity »

klownboy wrote:Hi serendipity, I like your new version 2. I went to bed last night thinking the original version, that wasn't timed, is still worthwhile, and I woke up and saw that you've incorporated the best of both, timed and manual collapse.
Actually, the only reason i made v2 was to incorporate not the manual or the timed collapse but the auto-collapse feature which is now the default and my favorite. :)
klownboy wrote: I have your new version working with a left or right click which would add different CTBs. Something like this in the beginning...

Code: Select all

 if (<get trigger> == 1) {
   $added_CTBs = "ctb10,ctb14,ctb15"; }
 if (<get trigger> == 2) {
   $added_CTBs = "cks,cfi,cbx"; }
and then I use the "$added_CTBs" variable later to establish $newtoolbar.
Yes, with SC toolbar() the possibilities are endless.
klownboy wrote: One item I was wondering about even before you posted version 2 though has nothing to do with left or right click, it has to do with $curctb and if you have a timed collapse, where $collapse is either -1 or any positive number, the variable $curctb really doesn't need to be on the new toolbar, only the new additions have to be there (i.e., why would you need $curctb in the timed state because you know if you don't do anything it's going away in "x" number of second anyway). On the other hand if you have $collapse set to "0" for a manual collapse it is absolutely necessary. So I added something like this...

Code: Select all

               if ($collapse == "0") {
               $newtoolbar=replace($toolbar,"$curctb","$curctb,$added_CTBs,-") ; }
               else {$newtoolbar=replace($toolbar,"$curctb","$added_CTBs,-") ; }
I'm still working on the CTBstates though between left and right click so I'm not adding the right click CTBs in $added_CTBs and then adding the left click CTBs cumulatively. It's getting a little hairy... :)
My idea from the beginning was to keep the old toolbar and add certain buttons into it and close it or whatever user preferred. From what i know changing the toolbar too much becomes counter-intuitive as one has to go hunting for the right buttons. But if you have several buttons to be added then buttons on fresh toolbar will serve better space-wise.
klownboy wrote: I suppose if we wanted to get really fancy and stick with just a left click as you have it, you could have the right click bring up a edit menu with a listing of the CTBs and select which ones you want to add. Thanks again for the script. It will become very handy.
Ken
Yes, that will be interesting. But i usually also put Edit script in the right-click to quickly access script and user settings.
Also, please feel free to showcase your toolbars and ideas with left/right click on a new thread. I don't want to restrict you to this thread which serves as Expand Drive button only.

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Expandable drive button

Post by serendipity »

admin wrote:And I actually had meant this as a reply to Marco:
Marco wrote:Also, an external script executor like XYcopy would be a killer feature for scripters... :whistle: ...
Oh ok.
I was wanting to ask and i think that's what Marco too wanted answered:
When I run a script using /flg=2, it runs in a different process right? as in different process ID from current XY process?

admin
Site Admin
Posts: 64917
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Expandable drive button

Post by admin »

serendipity wrote:When I run a script using /flg=2, it runs in a different process right? as in different process ID from current XY process?
Yep.

klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Expandable drive button

Post by klownboy »

Hey serendipity,

You're absolutely right, your auto-collapse feature is definitely the way to go. I hadn't actually tried it before my previous post. I'd say I'd be using the auto-collapse feature or manual collapse. I suppose I could set that up such that the left click did auto and right click did manual.

I worked out my issues with implementing left and right click with your script. The trick was be able to recognize if someone clicked with the left mouse button after having originally pressed the CTB with the right and visa versa. I had to set a permanent variable to flag which type of click was made initially to know if it was different the next click and use that information along with CBTstate being "1" pressed to do a reset. Still testing it though.

Edit 1: Is there some reason you didn't use the perm variable $p_toolbar instead of $toolbar in this line where you essentially reset to CTBstate "0"?

Code: Select all

$oldtoolbar=replace($toolbar,"$curctb,{drives_fix},-","$curctb");
I was also curious if there was any reason why you didn't unset $p_toolbar at the end of the "_waitcollapse", "_autocollapse" (i.e., since the state is reset back to "0")? I could see keeping the permanent variable for the manual option, but why for the auto and wait options?

Edit 2: I came across an issue which is also present in your version 2 of "expanddrivebutton.xys". I first saw it on my modified version, only in the waitcollapse mode. After pressing the CTB button initially, you press the same CTB (i.e., the original button assigned, not one of the expansion drive buttons) a second time during the wait period (I'm using 5 seconds) you will receive an error message, "Invalid button index: 0". I've been stepping through the script, but it's difficult to determine exactly what is happening. Obviously, pressing the CTB a second time within the wait period should simply reset the state back to "0", but it's still in the wait state so when the time is up (5 seconds), the variables are probably fouled up. Possibly one way to handle this error would be to recognize when in the waitcollapse mode and the ctbstate is already "1" then hitting the same CTB again would have no affect since the expanded CTBs will go away automatically in a matter of seconds. The other way would be to some how cancel the wait state in progress (I'm not sure if that's possible). I should also note that the same error will surface if you hit one of the expanded drive buttons and then go back and hit the original CTB within the wait period. I suppose this issue would be one argument for "replacing" the CTB with the expansion buttons in lieu of adding them to the CTB for waitcollapse mode... the CTB wouldn't be there to press. :)

Thanks again,
Ken

klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Expandable drive button

Post by klownboy »

Hi serendipity, I didn't get a chance to get back sooner, but I did resolve the error message issue I explained in my above post Edit 2. I probably wouldn't be using the wait collapse option, but I wanted to take care of it anyway. I simply inserted a flag using a permanent variable in indicate when the script was in a "wait" state. The script checks if you attempt to run the script again by clicking on the CTB.

Code: Select all

else { perm $wait = "ON";
  run "cmd /c ping -n $collapse 127.0.0.1 >nul & cd /d <xypath> & xyplorer.exe /script=""::load 'ExpandDriveButton.xys','_WaitCollapse'"" /flg=2", , 0,0; }
and then in the beginning on the script I added this if statement after the two lines that set the on / off icons...

Code: Select all

if (($collapse >= "1") AND ($wait = "ON") AND (ctbstate(,$p_ctbindex) == 1)) {end(1==1);}
I also unset the $wait variable at the end of the sub "_wait" and unset $p_toolbar in sub "_waitcollapse and "_autocollapse".
Thanks for the handy script. When you think about it, you could actually use this script with modification, as a substitute for a drop down menu. The trick is finding the right categories and associated CTBs to be expanded when the lead CTB is pressed.
Ken

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Expandable drive button

Post by serendipity »

Hi Ken,
I did not look into it carefully, been busy lately. Thanks for fixing though!

Filehero
Posts: 2713
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Expandable drive button

Post by Filehero »

Hi serendipity (and Ken :wink: ),

with the new breadcrumbs I think this expandable button comes in really handy.

But with the current beta 13.10.0115 I get the following issues with the script downloaded from the opening post.
1) No matter what $collapse is set to, upon expansion I get always another XY instance opened on top. :?:

2) Additionally with e.g. $collapse=3 on the new instance the following SC error pops up.
ExpDrvButton_SCError.png
ExpDrvButton_SCError.png (6.92 KiB) Viewed 3567 times
Edit: my CTB has number #32 which I also used to set $p_ctbindex.


May I have picked an older script version?

Anyway, nice idea/script.


Cheers,
Filehero

klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Expandable drive button

Post by klownboy »

Hi Filehero, So did it seem to work properly before v13.10.0115 or did you first try it after updating to that version? It is a very useful great little script that serendipity concocted. My personnel script based on serendipity's first post, as you might imagine from the later posts, is quite bastardized. I'm not using it for drive expansion, but expansion of CTBs I've selected and different ones expand for left click and different CTBs for right click along with different icons for off and on. Anyway, I downloaded the script in post one and loaded it with a new CTB and it worked fine using v13.10.0115. Are you sure you used the CTBindex as "32" not #32 (e.g., $p_ctbindex="32";). I received an invalid button index when I had #32 or in my case #18...you're running out of buttons! If you haven't yet, once you resolve your issue, try "$collapse=-1;". It's definitely the way to go.
Take care,
Ken

Filehero
Posts: 2713
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Expandable drive button

Post by Filehero »

Hi Ken,

yes, it's my first try after updating to v13.10.0115.

I added the index properly without the hash (though it doesn't matter if it's quoted or not). Testwise I changed the script to use user button #10 (with plenty of free buttons remaining). However, the problem of the second popping XY instance is the same. When I have more time I'll try to hunt that down.

Thanks for help!

Cheers,
Filehero

klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Expandable drive button

Post by klownboy »

Hi Filehero,
In trying to resolve the issue, please take a look at my two post starting here http://www.xyplorer.com/xyfc/viewtopic. ... =30#p93023 that concerned the timed wait option for drive collapse. I experienced something similar to what you have until I made the changes discussed. Also, when you hit the drive button a second time during wait mode strange things will happen. Script changes I discuss were made to make sure a second press of the original drive button does nothing in the wait mode until the time has lapsed. Note the changes addressed on permanent variables.

Also make sure the script called has not been renamed or the run in this line will not function properly unless you change the script name.

Code: Select all

run "cmd /c ping -n $collapse 127.0.0.1 >nul & cd /d <xypath> & xyplorer.exe /script=""::load 'ExpandDriveButton.xys','_WaitCollapse'"" /flg=2", , 0,0;
I know you are using Windows 8...you can use serendipity's earlier command

Code: Select all

run "cmd /c timeout $collapse & cd /d <xypath> & xyplorer.exe /script=""::load 'ExpandDriveButton.xys','_WaitCollapse'"" /flg=2", ,0,0;
instead. It can only be used on Windows 7 and above due to the use of the newer "timeout" command. I think serendipity may have take it out of version 2 such that the line worked across all systems.
Good luck. I can send you my version via PM if you want (I've been using it for a few weeks now without a problem).

Ken

Filehero
Posts: 2713
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Expandable drive button

Post by Filehero »

Hi Ken,

just a quick thanks.

I guess I have to dig a little bit deeper here.


Cheers,
Filehero

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Expandable drive button

Post by serendipity »

Updated first post. Fixed a bug.

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Expandable drive button

Post by serendipity »

Filehero wrote:Hi Ken,

just a quick thanks.

I guess I have to dig a little bit deeper here.


Cheers,
Filehero
Hi Filehero,
What happens when you run this addressbar?

Code: Select all

run "cmd /c cd /d <xypath> & xyplorer.exe /script=""::msg 'Hi!';"" /flg=2", , 0,0; 

Filehero
Posts: 2713
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Expandable drive button

Post by Filehero »

Hi,
serendipity wrote:What happens when you run this addressbar?

Code: Select all

run "cmd /c cd /d <xypath> & xyplorer.exe /script=""::msg 'Hi!';"" /flg=2", , 0,0; 
a new XY instance opens in the foreground which then creates the "Hi!" popup. What do you expect to happen?

Obviously I'm the only one having this problem. Strange.

Thanks for helping.


Cheers,
Filehero

Post Reply