Clean Recent Menu

Discuss and share scripts and script files...
nerdweed
Posts: 648
Joined: 25 Feb 2012 07:47

Re: Clean Recent Menu

Post by nerdweed »

The previous upload had a missing parenthesis that cause the list to be dimmed for all Copy and Move. And there wasn't anything to handle the Copy and Move either.

New version. It mimics Recent Locations (shows paths with number) when Sorted and Grouped is No and mimics HotList (No numbers) when Sorting and Grouping is on.

Heredoc resolves the variable names and hence, it wasn't self sufficient to be stored directly with the CTB. Have worked around that and this is self sufficient.

Thanks LittleBig for this script. My UDC is now ready

Code: Select all

"HitList"
  perm $P_MRU ; 
  $var_P_MRU = '$P_MRU' ;
  $var_new_limit = '$new_limit' ;
  $P_MRU = ($P_MRU == "" )? "|AL:32|SAG:Yes|ACT:Goto|" : $P_MRU ;
  $limit = RegExMatches ($P_MRU,"\|AL:WA|\d+") ; //WA is a workaround
  $sag = RegExMatches ($P_MRU, "\|SAG:WA|Yes|No") ;
  $act = RegExMatches ($P_MRU, "\|ACT:WA|Goto|MoveTo|CopyTo");
  $count = 0;
  $CleanList = "";

  $state = "";
  if ( (!get("CountSelected")) && ($act != "Goto")) { $state="|4"; }

  foreach($RecPath, get("list_recentlocations"), <crlf>,, "") {
    if ($count < $limit) {
      if (substr($RecPath,0,2) == "\\" ||  exists($RecPath) > 0) { //Assume Network paths are available
        $count++;
        $CleanList = $CleanList . '"' . format($count,"00") . " - " . $RecPath . "| $RecPath" . $state . '" ' . $act . ' "' . $RecPath . '"' . "<crlf>";
      }
    }
    else {
      break;
    }
  }
  $CleanList = formatlist($CleanList,"e","<crlf>");
  if ($sag == "Yes") {
    $Grouped = RegExReplace ($CleanList,"\d+ - (.+)","$1") ;
    $Grouped = formatlist($Grouped,"s","<crlf>");
    $CleanList = "";
    $LastLetter = substr($Grouped,1,1);
    foreach($path, $Grouped, <crlf>,, "") {
      if ($LastLetter != substr($path,1,1)) {
        $CleanList = $CleanList . "-" . <crlf>;    
      }
      $LastLetter = substr($path,1,1);
      $CleanList = $CleanList . $path . <crlf>;
    }
  }

  if ($act=="Goto") {$goto="|2" ; $copy="" ; $move="" ; }
  elseif ($act=="CopyTo") {$copy="|2" ; $move="" ; $goto="" ;}
  elseif ($act=="MoveTo") {$move="|2" ; $goto="" ; $copy="" ; }

  $MENU=<<<FOO
"Actual Limit: $limit|:rename" 
  $var_new_limit = input("New limit:",,$limit)*1;
  $var_P_MRU = Replace($var_P_MRU, "AL:$limit|", "AL:".$var_new_limit."|", 1);
"Sorted and Grouped: $sag |:sort" 
  if ($sag == "Yes") {
    $var_P_MRU = RegExReplace($var_P_MRU, "\|SAG:Yes\|", "|SAG:No|", 1);
  }
  else {
    $var_P_MRU = RegExReplace($var_P_MRU, "\|SAG:No\|", "|SAG:Yes|", 1);
  }
"Goto|:labels $goto"
  $var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:Goto");
"Copy|:labels $copy" 
  $var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:CopyTo");
"Move|:labels $move" 
  $var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:MoveTo");
"-"
FOO;
  $MENU=$MENU . <crlf> . $CleanList ;
  load "$MENU", * , 's';
Edit: edited the code a little bit, no changes functionality wise
Last edited by nerdweed on 26 Apr 2014 22:06, edited 4 times in total.

LittleBiG
Posts: 1846
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: Clean Recent Menu

Post by LittleBiG »

Perfect, nerdweed :appl: Thanks for the numbering! I wasn't able to produce it, because my mind was stuck at using |* as an icon and with the numbers the icons weren't shown any more. And thanks also for driving my attention to the load command when it uses a script as an argument. I have never used that before.

May I ask why did you use WA?

Code: Select all

$limit = RegExMatches ($P_MRU,"\|AL:WA|\d+") ; //WA is a workaround
Wouldn't this be enough?

Code: Select all

$limit = RegExMatches ($P_MRU,"\d+") ;

nerdweed
Posts: 648
Joined: 25 Feb 2012 07:47

Re: Clean Recent Menu

Post by nerdweed »

I don't know :oops:

This would have been enough
$limit = RegExMatches ($P_MRU,"\d+") ;
However; for the sorting and action, I wasn't able to pull the first choice, in other words - that regex can never pull WA out (don't know why - not very good with RegEx - very can be skipped as well)

So for the sake of keeping all three options with the same regex, I used that line. In the current scenario, I don not need to use AL:/SAG:/ACT: either as valid options for them will not coincide, but thought about keeping it that way. If this can be pulled some other way then let me know.
Thanks for the numbering! I wasn't able to produce it, because my mind was stuck at using |* as an icon and with the numbers the icons weren't shown any more.
I faced that as well. But not having to think on the logic for the main functionality, I had a less busy mind to work with the aesthetics.

Editing the previous post as I managed to avoid some checks in the sorting and grouping section.

Edit: Is the Hotlist list also exposed somewhere. Might make a good addition

nerdweed
Posts: 648
Joined: 25 Feb 2012 07:47

Re: Clean Recent Menu

Post by nerdweed »

Here's one with Hotlist as well - Hotlist doesn't adhere to the limit set. You will have to unset the PV first.

Code: Select all

"HitList"
  perm $P_MRU ; 
  $var_P_MRU = '$P_MRU' ;
  $var_new_limit = '$new_limit' ;
  $P_MRU = ($P_MRU == "" )? "|AL:32|Order:Recent|ACT:Goto|" : $P_MRU ;
  $limit = RegExMatches ($P_MRU,"\|AL:WA|\d+") ; //WA is a workaround
  $Order = RegExMatches ($P_MRU, "\|Order:WA|Recent|Grouped|HotList") ;
  $act = RegExMatches ($P_MRU, "\|ACT:WA|Goto|MoveTo|CopyTo");
  $CleanList = "";
  $state = "";
  if ( (!get("CountSelected")) && ($act != "Goto")) { $state="|4"; }

  if ($Order != "HotList") {
    $count = 0;
    foreach($RecPath, get("list_recentlocations"), <crlf>,, "") {
      if ($count < $limit) {
        if (substr($RecPath,0,2) == "\\" ||  exists($RecPath) > 0) { //Assume Network paths are available
          $count++;
          $CleanList = $CleanList . '"' . format($count,"00") . " - " . $RecPath . "| $RecPath" . $state . '" ' . $act . ' "' . $RecPath . '"' . "<crlf>";
        }
      }
      else { break; }
    }
  }

  else {
    $PrevPath = "" ;
    foreach($RecPath, formatlist(get("list_recentlocations"),"s","<crlf>"), <crlf>,r, "") {
      if (substr($RecPath,0,2) == "\\" ||  exists($RecPath) > 0)  {
        $Check = Replace($PrevPath,$RecPath,"",) ;
        if ($Check == $PrevPath ) {
          $CleanList = $CleanList . '"' . $RecPath . "| *" . $state . '" ' . $act . ' "' . $RecPath . '"' . "<crlf>";
        }
        $PrevPath = $RecPath ;
      }  
    }
  }

  $CleanList = formatlist($CleanList,"e","<crlf>");
  if ($Order != "Recent") {
    if ($Order == "Grouped")  { $CleanList = RegExReplace ($CleanList,"\d+ - (.+)","$1") ;  }
    $Grouped = formatlist($CleanList,"s","<crlf>");
    $CleanList = "";
    $LastLetter = substr($Grouped,1,1);
    foreach($path, $Grouped, <crlf>,, "") {
      if ($LastLetter != substr($path,1,1)) {
        $CleanList = $CleanList . "-" . <crlf>;    
      }
      $LastLetter = substr($path,1,1);
      $CleanList = $CleanList . $path . <crlf>;
    }
  }

  if ($act=="Goto") {$goto="|2" ; $copy="" ; $move="" ; }
  elseif ($act=="CopyTo") {$copy="|2" ; $move="" ; $goto="" ;}
  elseif ($act=="MoveTo") {$move="|2" ; $goto="" ; $copy="" ; }

  $MENU=<<<FOO
"Actual Limit: $limit|:rename" 
  $var_new_limit = input("New limit:",,$limit)*1;
  $var_P_MRU = Replace($var_P_MRU, "AL:$limit|", "AL:".$var_new_limit."|", 1);
"Order: $Order |:sort" 
  if ($Order == "Recent") { $var_P_MRU = RegExReplace($var_P_MRU, "\|Order:Recent\|", "|Order:Grouped|", 1); }
  elseif ($Order == "Grouped") { $var_P_MRU = RegExReplace($var_P_MRU, "\|Order:Grouped\|", "|Order:HotList|", 1);  }
  else { $var_P_MRU = RegExReplace($var_P_MRU, "\|Order:HotList\|", "|Order:Recent|", 1);  }
"Goto|:labels $goto"
  $var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:Goto");
"Copy|:labels $copy" 
  $var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:CopyTo");
"Move|:labels $move" 
  $var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:MoveTo");
"-"
FOO;
  $MENU=$MENU . <crlf> . $CleanList ;
  load "$MENU", * , 's';

LittleBiG
Posts: 1846
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: Clean Recent Menu

Post by LittleBiG »

I don't like official hotlist, because it is based on a wrong assumptation. Quote from the help:
(5) It's compressed: only the *leaves* of the branches are displayed. If your history contains

C:\
C:\Programs
C:\Programs\XYplorer

then only the latter is shown in the Hotlist. It is assumed that the skipped parent items have just been transit stations on the way to the final "leaf" item,
They are transit locations only if they are next to each other! For example, I download files into the Downloads folder, and I extract them to a subfolder. So if my recent is like:

Code: Select all

05 - D:\Downloads\
06 - D:\Downloads\CCleaner\
, that really means D:\Download was a transit location. But if the situation is this:

Code: Select all

02 - D:\Downloads\CCleaner\
...
08 - D:\Downloads\
09 - C:\Windows\
it means, I visited the Downloads folder on purpose, and it was NOT a transit folder to CCleaner\, so I would like to see it in my hotlist.

I have invented a new kind of hotlist. It eliminates only the REAL transit paths (if they are neigbours.) In this way the limit gets a meaning again.

nerdweed
Posts: 648
Joined: 25 Feb 2012 07:47

Re: Clean Recent Menu

Post by nerdweed »

Makes sense. Let me try to get that in and see. After Don grants me the GetHeldKeys function - http://www.xyplorer.com/xyfc/viewtopic. ... 10#p103468
this thing can become even more amazing

Edit: With the HitList (small modification from hotlist). I like it as well

Code: Select all

"HitList"
	perm $P_MRU ; 
	$var_P_MRU = '$P_MRU' ;
	$var_input = '$user_input' ;
	$P_MRU = ($P_MRU == "" )? "|AL:32|Order:Recent|ACT:Goto|" : $P_MRU ;
	$limit = RegExMatches ($P_MRU,"\|AL:WA|\d+") ; //WA is a workaround
	$Order = RegExMatches ($P_MRU, "\|Order:WA|Recent|Grouped|HotList|HitList") ;
	$act = RegExMatches ($P_MRU, "\|ACT:WA|Goto|MoveTo|CopyTo");
	$CleanList = "";
	$state = "";
	if ( (!get("CountSelected")) && ($act != "Goto")) { $state="|4"; }
	
	if ($Order == "Recent" || $Order == "Grouped") {
		$count = 0;
		foreach($RecPath, get("list_recentlocations"), <crlf>,, "") {
			if ($count < $limit) {
				if (substr($RecPath,0,2) == "\\" ||  exists($RecPath) > 0) { //Assume Network paths are available
					$count++;
					$CleanList = $CleanList .'"' .format($count,"00") ." - " .$RecPath ."| $RecPath" .$state .'" ' .$act .' "' .$RecPath .'"' ."<crlf>";
				}
			}
			else { break; }
		}
	}
	else {
		$PrevPath = "" ;
		if ($Order == "HotList" )	{ $RecLoc = formatlist(get("list_recentlocations"),"s","<crlf>") ; }
		else { $RecLoc = get("list_recentlocations") ; }
		foreach($RecPath,$RecLoc , <crlf>,r, "") {
			if (substr($RecPath,0,2) == "\\" ||  exists($RecPath) > 0)  {
				$Check = Replace($PrevPath,$RecPath,"",) ;
				if ($Check == $PrevPath ) {
					$CleanList = $CleanList . '"' . $RecPath . "| *" . $state . '" ' . $act . ' "' . $RecPath . '"' . "<crlf>";
				}
				$PrevPath = $RecPath ;
			}  
		}
	}

	$CleanList = formatlist($CleanList,"e","<crlf>");
	if ($Order != "Recent") {
		if ($Order == "Grouped")  { $CleanList = RegExReplace ($CleanList,"\d+ - (.+)","$1") ;  }
		$Grouped = formatlist($CleanList,"s","<crlf>");
		$CleanList = "";
		$LastLetter = substr($Grouped,1,1);
		foreach($path, $Grouped, <crlf>,, "") {
			if ($LastLetter != substr($path,1,1)) {
				$CleanList = $CleanList . "-" . <crlf>;    
			}
			$LastLetter = substr($path,1,1);
			$CleanList = $CleanList . $path . <crlf>;
		}
	}
	if ($act=="Goto") {$goto="|2" ; $copy="" ; $move="" ; }
	elseif ($act=="CopyTo") {$copy="|2" ; $move="" ; $goto="" ;}
	elseif ($act=="MoveTo") {$move="|2" ; $goto="" ; $copy="" ; }
	
	$MENU=<<<FOO
"Actual Limit: $limit|:rename" 
	$var_input = input("New limit:",,$limit)*1;
	$var_P_MRU = Replace($var_P_MRU, "AL:$limit|", "AL:".$var_input."|", 1);
"Order: $Order |:sort" 
	$var_input = inputselect("Select Ordering","Recent|Sorted|HotList|HitList") ;
	$var_P_MRU = RegExReplace($var_P_MRU, "\|Order:WA|Recent|Grouped|HotList|HitList", "|Order:".$var_input);
"Goto|:labels $goto"
	$var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:Goto");
"Copy|:labels $copy" 
	$var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:CopyTo");
"Move|:labels $move" 
	$var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:MoveTo");
"-"
FOO;
	$MENU=$MENU . <crlf> . $CleanList ;
	load "$MENU", * , 's';

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

Re: Clean Recent Menu

Post by klownboy »

Thanks for the updates. :appl: I'm still tacking on the Favorite Folders and Files menus on the end of each update. :)

I agree with your request for something like a GetHeldKeys function in menus. It would also be nice to have a similar detection in the CTB itself (e.g., recognizing that shift key is held when the button is pressed or the middle mouse button (which if not present can certainly be simulated on most mice)). It would provide so much more flexibility in CTBs and menus while minimizing the need for additional buttons. Let's face it, so many of these button actions can be grouped together in some way.
Thanks again,
Ken
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

nerdweed
Posts: 648
Joined: 25 Feb 2012 07:47

Re: Clean Recent Menu

Post by nerdweed »

Are you adding Favorites along with the file operations stuff. Can you share the latest one written by you as well.

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

Re: Clean Recent Menu

Post by klownboy »

Hi nerdweed, yes, I'm using Favorite Files and Favorite Folders along with your and LittleBiG's CleanRecent or CleanList (in this case your latest posted CleanList).
CleanList.PNG
CleanList.PNG (23.1 KiB) Viewed 5479 times
Everything from "copying" to "goto" works fine. I assume the folders are supposed to be greyed out if you do not have any files selected to copy or move and as expected never greyed out in the goto mode. Please feel free to clean it up and post it especially if you find a better or alternative method.

Code: Select all

"HitList"
   perm $P_MRU ; 
   $var_P_MRU = '$P_MRU' ;
   $var_input = '$user_input' ;
   $P_MRU = ($P_MRU == "" )? "|AL:32|Order:Recent|ACT:Goto|" : $P_MRU ;
   $limit = RegExMatches ($P_MRU,"\|AL:WA|\d+") ; //WA is a workaround
   $Order = RegExMatches ($P_MRU, "\|Order:WA|Recent|Grouped|HotList|HitList") ;
   $act = RegExMatches ($P_MRU, "\|ACT:WA|Goto|MoveTo|CopyTo");
   $CleanList = "";
   $state = "";
   if ( (!get("CountSelected")) && ($act != "Goto")) { $state="|4"; }
   
   if ($Order == "Recent" || $Order == "Grouped") {
      $count = 0;
      foreach($RecPath, get("list_recentlocations"), <crlf>,, "") {
         if ($count < $limit) {
            if (substr($RecPath,0,2) == "\\" ||  exists($RecPath) > 0) { //Assume Network paths are available
               $count++;
               $CleanList = $CleanList .'"' .format($count,"00") ." - " .$RecPath ."| $RecPath" .$state .'" ' .$act .' "' .$RecPath .'"' ."<crlf>";
            }
         }
         else { break; }
      }
   }
   else {
      $PrevPath = "" ;
      if ($Order == "HotList" )   { $RecLoc = formatlist(get("list_recentlocations"),"s","<crlf>") ; }
      else { $RecLoc = get("list_recentlocations") ; }
      foreach($RecPath,$RecLoc , <crlf>,r, "") {
         if (substr($RecPath,0,2) == "\\" ||  exists($RecPath) > 0)  {
            $Check = Replace($PrevPath,$RecPath,"",) ;
            if ($Check == $PrevPath ) {
               $CleanList = $CleanList . '"' . $RecPath . "| *" . $state . '" ' . $act . ' "' . $RecPath . '"' . "<crlf>";
            }
            $PrevPath = $RecPath ;
         }  
      }
   }

   $CleanList = formatlist($CleanList,"e","<crlf>");
   if ($Order != "Recent") {
      if ($Order == "Grouped")  { $CleanList = RegExReplace ($CleanList,"\d+ - (.+)","$1") ;  }
      $Grouped = formatlist($CleanList,"s","<crlf>");
      $CleanList = "";
      $LastLetter = substr($Grouped,1,1);
      foreach($path, $Grouped, <crlf>,, "") {
         if ($LastLetter != substr($path,1,1)) {
            $CleanList = $CleanList . "-" . <crlf>;    
         }
         $LastLetter = substr($path,1,1);
         $CleanList = $CleanList . $path . <crlf>;
      }
   }
   if ($act=="Goto") {$goto="|2" ; $copy="" ; $move="" ; }
   elseif ($act=="CopyTo") {$copy="|2" ; $move="" ; $goto="" ;}
   elseif ($act=="MoveTo") {$move="|2" ; $goto="" ; $copy="" ; }

 $FavCount = getkey("Count", "FavFiles");
   if($FavCount == "0") {$Favs = "No favorite files"}
    else {
      $Favs = "";
      $i = 1;
    while ($i <= $FavCount) {
      $a = getkey("Fav$i", "FavFiles");
      $Favs = $Favs . $a . "<crlf>";
      $i++;
      }
    }
   $FavFiles = "-" . "<crlf>" . "   FAVORITE FILES  " . "<crlf>" . "$Favs" . "-" . "<crlf>"; 

  $FavFolderCount = getkey("Count", "Favorites");
   if($FavFolderCount == "0") {$FFs = "No favorite folders";}
    else {
      $FFs = "";
      $i = 1;
    while ($i <= $FavFolderCount) {
       $a = getkey("Fav$i", "Favorites");
         if(substr(gettoken($a, 1, ":"), -4) == "DUAL") {
           $a = gettoken($a, 1, '" ') . '|:panellast"' . " goto " . '"' . gettoken($a, 2,'" ') . '"';}
           else { }
       $FFs = $FFs . $a . "<crlf>";
       $i++;
       }
    }
   $FavFolders = "   FAVORITE FOLDERS  " . "<crlf>" . "$FFs"; 

  $MENU=<<<FOO
"   RECENT FOLDERS  ";
"Actual Limit: $limit|:rename" 
   $var_input = input("New limit:",,$limit)*1;
   $var_P_MRU = Replace($var_P_MRU, "AL:$limit|", "AL:".$var_input."|", 1);
"Order: $Order |:sort" 
   $var_input = inputselect("Select Ordering","Recent|Sorted|HotList|HitList", ,8) ;
   $var_P_MRU = RegExReplace($var_P_MRU, "\|Order:WA|Recent|Grouped|HotList|HitList", "|Order:".$var_input);
"Goto|:labels $goto"
   $var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:Goto");
"Copy|:labels $copy" 
   $var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:CopyTo");
"Move|:labels $move" 
   $var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:MoveTo");
"-"
FOO;
  $MENU=$MENU . <crlf> . $CleanList.$FavFiles.$FavFolders ;
  load "$MENU", * , 's';
[/size]Thanks again,
Ken
CleanList_w_Favs.zip
(1.46 KiB) Downloaded 236 times
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

nerdweed
Posts: 648
Joined: 25 Feb 2012 07:47

Re: Clean Recent Menu

Post by nerdweed »

I haven't checked much on this. I have a CTB that populates Fav Folders on Left Click and Fav Files on Right Click.

BTW, you can read the whole section from ini file at once rather than reading it one at a time

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

Re: Clean Recent Menu

Post by klownboy »

Hi and thanks nerdweed, when you referred to reading a whole section of the ini file as opposed to each line in a section, were you referring a technique similar to what SkyFrontier used to hiLite favorite files post?

Code: Select all

  $a = gettoken(gettoken(gettoken(readfile("<xydata>\<xyini>"), 2, "<crlf>[FavFiles]"), 1, "<crlf>["), 3, <crlf>, , 2); text $a;
I also came across these techniques in this thread http://www.xyplorer.com/xyfc/viewtopic. ... t=continue Do you think in this case that would make much of a difference in execution speed? I think we'd still need a "while" or "foreach" loop to single out the info needed. As you were saying, to display the Favorite Files or Favorite Folders is quite simple if you set it up as a right and left click of a CTB since you can simply use the Command ID, like #564 and the menu pops up. As you know though, you can't incorporate the command as part of a another menu since the favs will come up as sub menu unless I'm missing something...and I'm sure I am.
Thanks,
Ken
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

nerdweed
Posts: 648
Joined: 25 Feb 2012 07:47

Re: Clean Recent Menu

Post by nerdweed »

You linked the right thread, though I was referring to Don's post http://www.xyplorer.com/xyfc/viewtopic. ... nue#p92083

And then gettokens and other functions to generate the Favorite lists
As you were saying, to display the Favorite Files or Favorite Folders is quite simple if you set it up as a right and left click of a CTB since you can simply use the Command ID, like #564 and the menu pops up. As you know though, you can't incorporate the command as part of a another menu since the favs will come up as sub menu unless I'm missing something...and I'm sure I am.
No, you are not :)

The ini method always has the exception of missing those favorites that were added/removed after the last save. You would end up reading the file m+n times every time the menu is invoked. If you still need them in a single menu, if you read the whole section at once, it would be only two reads. This is all could have been so cute, if the fav lists were also exposed.

I was just wondering why you would want all that in a single menu unless you have a very tall monitor (but even in that case, it might have enough space to accomodate an extra CTB with LC as favfolders and RC as favfiles.)

Edit: Haven't checked that fancy gettoken series. Will check that in the evening.

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

Re: Clean Recent Menu

Post by klownboy »

Yes, I found that interesting how Don, in knowing a Null character separates the keys, used that information to obtain the list of keys in a particular section. Once you get the keys in a section like [FavFiles] (e.g., Fav1, Fav2, etc.) wouldn't you be forced to use getkey again to obtain the "values" for each key, which is what we are after in this case or is there someway around that?

Code: Select all

  $ListOfKeysInSection = getkey("", "FavFiles", "<xydata>\<xyini>");
  $myfavs = "";
  $keys = replace($ListOfKeysInSection, chr(0), "<crlf>"); //text $keys;
    foreach($line, $keys, "<crlf>") {
      if(($line == "Count") OR ($line == "")) {continue;}
      else {
        $a = getkey($line, "FavFiles");
        $myfavs = $myfavs . $a . "<crlf>";
       }
      }
   text $myfavs;
It wouldn't seem that doing it this way would be any faster than the way I did it in the previously posted script which was similar to this below. I suppose we could also use readfile and gettoken to obtain the "values" of the obtained keys, but that seems like even more work than using getkey again.

Code: Select all

 $FavCount = getkey("Count", "FavFiles");
      $Favs = "";
      $i = 1;
    while ($i <= $FavCount) {
      $a = getkey("Fav$i", "FavFiles");
      $Favs = $Favs . $a . "<crlf>";
      $i++;
      }
    text $Favs;
This time I think I may be missing something. :)

By the way, I did originally add Favorite Files and Folders to the Clean Recent/List menu only to see if I could do it, but after using it awhile I found it was quite useable. I keep the Recent folders menu limit to only 10 and the favorites menus to less than 6 or 7 so there's no problem with it being too long.

Edit: I weeded out some code in the 2nd example which didn't apply to the comparison of the 2 examples.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

nerdweed
Posts: 648
Joined: 25 Feb 2012 07:47

Re: Clean Recent Menu

Post by nerdweed »

I thought the conditional statements in XY where short circuit, but they don't happen to be. So, the earlier script would have checked for existence of network paths as well.

Revised version attached
Attachments
HitList.xys
(5.91 KiB) Downloaded 234 times

LittleBiG
Posts: 1846
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: Clean Recent Menu

Post by LittleBiG »

nerdweed wrote:I thought the conditional statements in XY where short circuit, but they don't happen to be. So, the earlier script would have checked for existence of network paths as well.
Thanks, nerdweed. Smart idea.

Post Reply