CEA for a Toolbar Button set switch

Features wanted...
klownboy
Posts: 4147
Joined: 28 Feb 2012 19:27

Re: CEA for a Toolbar Button set switch

Post by klownboy »

Many users of XYplorer also use AHK. There might be some interest in this small AHK script that you could put in your AHK startup file. It simply detects a scroll accomplished over XY's toolbar. You could use it to run a script which you want to run on one particular toolbar or a different script for a second toolbar. For me I use it to place the address bar on toolbar button set #2, line 1, and the script also changes a CTB indicating which toolbar is active or current. This same CTB also switches toolbars like scrolling does. Scrolling to other toolbars only works if you don't have toolbar scrolling enabled in TB options. I can post the XY script as well if anyone wants it. The code is in AHK v1 though I'm sure someone could write the V2 equivalent.

Code: Select all

#If isMouseOver("ThunderRT6PictureBoxDC",[66,67,72,73])
~WheelUp::
~WheelDown::
SendInput ^!{Numpad5}  ;runs a UDC which in turn runs a script when scrolling TB
;soundbeep
return
#If

isMouseOver(controlName, controlNums) {
MouseGetPos,,,, controlNameUnderMouse

for each, controlNum in controlNums
   if (controlNameUnderMouse = controlName . controlNum)

;also works
;Loop % controlNums.Length()
;   if (controlNameUnderMouse = controlName . controlNums[A_Index])

;also works
;For index, value in controlNums
;   if (controlNameUnderMouse = controlName . value)

		return 1
	return 0
}
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

autocart
Posts: 1248
Joined: 26 Sep 2013 15:22

Re: CEA for a Toolbar Button set switch

Post by autocart »

klownboy wrote: 08 Apr 2024 20:33 Many users of XYplorer also use AHK. There might be some interest in this small AHK script that you could put in your AHK startup file. ... I can post the XY script as well if anyone wants it. ...
Thank you, klownboy. That is a very nice thing to do.
I don't have an urgent need for the XY script but if you have time and energy left, I am sure it will be interesting to look at it as well.
Thank you again.

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

Re: CEA for a Toolbar Button set switch

Post by klownboy »

Hey autocart thanks for the interest. My main goal in the XY script was to use a single script to switch toolbars whether it be by scrolling or UDC or CTB. Regardless of the method used, it will change the CTB indicating the toolbar button set #. And for my use, I have the address bar displayed only on toolbar button set #2 Line #1. You can obviously do something different.
Important: the script must be first run from the CTB (not scrolling or UDC so that the CTB index is obtained)

Assigments in CTB and UDCs(2):
CTB name "TB Cycle with Indicator" in left and right click: load "<xyscripts>\TB Cycle with Indicator.xys";
UDC name: "TB Cycle with Indicator in "Run script" category: load "<xyscripts>\TB Cycle with Indicator.xys"; I have it set to Numpad5
UDC name: "TB Cycle with Indicator- scrolling" in "Load script file" category: global $UDC="1";load "<xyscripts>\TB Cycle with Indicator.xys"; I have this set to Control Alt Numpad5. This is the key combo actuated by AHK (see my previous AHK script post)

Code: Select all

   global $UDC;
   $loc = ControlatPos();
   $trigger = get("trigger","mousebtn");
   $ctbindex = "unknown";
//*** On first run only, determine & set CTB index [$ctbindex below] based on CTB name
//*** So we can use this in a UDC as well as a CTB. Run this script from CTB first
//*** If you want to simply put in your $ctbindex above, you can delete this section 
   if($ctbindex LikeI "unknown") {
      $self = self("file");
      $toolbar = toolbar();
      $name_CTB = ctbname();
      foreach($button, $toolbar, ",") {
         if(substr($button, 0, 3) LikeI "ctb") {
           $ctbI = trim($button, "ctb", "L");
           if(ctbname( , $ctbI) == "$name_CTB") {
           $ctbindex = $ctbI; break;
           }
         }
       }
      $content = replace(readfile($self), "unknown", "$ctbindex", , 1, 1);
      writefile($self, $content);
   }

   if($UDC == "1" AND !$trigger) {   //if scrolled $trigger will be "0"
      ButtonSet(-1);                 //or use: button "tbs"; with same result
   }
   elseif(!$trigger AND gettoken($loc, "1", "|") LikeI "T*") {
   }
   else {
      ButtonSet(-1);
   }

   $n = ButtonSet();
   if($n == "1") {
      if(get("#660")) {#660;}    // setlayout("ShowAddressbar=1");
   }
   elseif($n == "2") {
      if(!get("#660")) {#660;}   // setlayout("ShowAddressbar=1");
   }

   ctbname("Toolbar Set #" . $n, $ctbindex);
   ctbicon("label: $n >554433,FFF2F2", $ctbindex);
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Post Reply