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 »

As Don has provided an option to check for held keys, here we go with the modified version

If the script is invoked whilst holding
Shift - Sorted menu
Ctrl - HotList
Ctrl+Shift - HitList
None/Others - Recent Menu

After the menu is displayed, if the menu items are clicked whilst holding
Ctrl - Copies selected item to the clicked directory
Shift - Moves selected item to the clicked directory
None/Others - Goto the selected item

Why not Alt - Alt misbehaves on context menus

Code: Select all

"HitList"
	$mod = get("shift");
	$limit = 32;
	$order = "Recent";  //No (or any other) modifier keys
	If ($mod == 1) { $order = "Sorted"; } //Shift
	ElseIf ($mod == 2) { $order = "HotList"; } //Ctrl
	ElseIf ($mod == 3) { $order = "HitList"; } //Ctrl+Shift

	$CleanList = "";
	if ($order == "Recent" || $order == "Sorted") {
		$count = 0;
		foreach($RecPath, get("list_recentlocations"), <crlf>,, "") {
			if ($count < $limit) {
				if (substr($RecPath,0,2) == "\\") { $flag=1; } //Assume Network paths are available
				Else { $flag = exists($RecPath) ; }
				if ($flag > 0) {
					$count++;
					$CleanList = $CleanList . '"' . format($count,"00") . " - $RecPath|$RecPath" . '"' . " 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) == "\\" )  { $flag=1; }
			Else { $flag = exists($RecPath) ; }
			If ($flag > 0) {
				$Check = Replace($PrevPath,$RecPath,"",) ;
				if ($Check == $PrevPath ) {
					$CleanList = $CleanList . '"' . "$RecPath|$RecPath" . '"' . " Act($RecPath);" . "<crlf>";
				}
				$PrevPath = $RecPath ;
			}  
		}
	}
	$CleanList = formatlist($CleanList,"e","<crlf>");
	if ($order != "Recent") {
		if ($order == "Sorted")  {
			$CleanList = RegExReplace ($CleanList,"\d+ - (.+)","$1") ; 
		}
		$Sorted = formatlist($CleanList,"s","<crlf>");
		$CleanList = "";
		$LastLetter = substr($Sorted,1,1);
		foreach($path, $Sorted, <crlf>,, "") {
			if ($LastLetter != substr($path,1,1)) {
				$CleanList = $CleanList . "-" . <crlf>;    
			}
			$LastLetter = substr($path,1,1);
			$CleanList = $CleanList . $path . <crlf>;
		}
	}
	load "$CleanList", * , 's';
	
function Act($loc)
{
	$mod = <get shift>;
	If ($mod == 2) { //Ctrl
		CopyTo $loc ;
	}
	ElseIf ($mod == 3) { //Ctrl+Shift
		MoveTo $loc ;
	}
	Else {	//No (or any other) modifier keys
		GoTo $loc ;
	}
}
[/size]
Last edited by nerdweed on 25 Sep 2015 23:45, edited 1 time in total.

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

Re: Clean Recent Menu

Post by klownboy »

Cool nerdweed, you're way ahead of me in testing and implementing Don's new modifier capabilities. I wasn't sure if we'd be able to detect the modifier when the script is implemented but obviously you can. Originally I thought we'd be only able to use it when clicking in a menu. This opens up some real possibilities. I've already tried this and another script referenced in "CEA_ListRightClickOnWhite_Script= Load ...." in XYplorer.ini to bring up different menus when clicking on WhiteSpace in the List and Tree depending on what modifier you have pressed. This really opens up some great potential in XY scripting. A great addition for my WhiteSpaceCtxMenu and Vertical Toolbar scripts and who knows how many others. :tup:
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 »

Indeed, we can get the modifier keys, but that should be stored as soon as the click is registered i.e; the first statement after the click.

Edit:
I need to make it a bit more like Don's handling i.e; After the menu is displayed, if the menu items are clicked whilst holding
Shift - Goto the selected item in new tab
Ctrl+Shift - Goto the selected item in other pane
Ctrl - Copies selected item to the clicked directory
Alt+Ctrl - Moves selected item to the clicked directory (Ctrl+Alt won't work nicely, because the menu won't be shown)
None/Others - Goto the selected item

It would need some work, will upload it tomorrow.

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

Re: Clean Recent Menu

Post by nerdweed »

Here Comes V2

Whilst Invoking
Shift - Sorted menu
Ctrl - HotList
Ctrl+Shift - HitList
None/Others - Recent Menu


On Menu
Shift - Goto the selected item in new tab
Ctrl+Shift - Goto the selected item in other pane
Ctrl - Copies selected item to the clicked directory
Alt+Ctrl - Moves selected item to the clicked directory (Ctrl+Alt won't work nicely, because the menu won't be shown)
None/Others - Goto the selected item

Orders
All, without invalid paths
Recent - Recent locations
Sorted - Sorted list of above (unlike Recent, doesn't show the numbers)
HotList - Like Hotlist (For some reason, shows paper folders instead of Recycle bin, and I like it. The current location isn't bolded if it is in the HotList)
HitList - Similar to Hotlist but only adjacent paths are considered as transit locations (and removed) only if they are next to each other!

There was a small bug in HitList - If parent directory was navigated after a child location, it shouldn't be removed but was being. Fixed.
Attachments
HitList.xys
(5 KiB) Downloaded 178 times

Stef123

Re: Clean Recent Menu

Post by Stef123 »

Thank you nerdweed,
up til now I had been using LittleBig's original script. But with your additions it's become very tempting to use your fork instead. Great idea and very intuitive handling of modifier keys. However, there are some things missing in your fork:
- Seeing other drives as well, not just the current drive
- Sorted and GROUPED (I know I can Shift-click to get sorted)
- setting an actual limit from within the popup

Not sure if you have the time and intention to match these features of the original script - just thought I'd point it out.

Some issues:
1) After cleaning out the recent list (thanks to Ken's HouseCleaning script), I get the following error in line 75

Code: Select all

load "$CleanList", * , 's';

Error message:
Command 'load' called with empty 'resource' argument.
2) When Ctrl-clicking WITHOUT a selection in list view:

Code: Select all

CopyTo $loc;

Error message:
Command 'copyto' failed or was canceled.

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

Re: Clean Recent Menu

Post by nerdweed »

Thanks Stef.

1. Seeing other drives as well, not just the current drive - Do you wish to see only the current drive. I don't think I would like that behavior but in the next version I upload, I will keep a line for it. You would just need to uncomment it. I will let you know the line number

2. Sorted and GROUPED (I know I can Shift-click to get sorted) - Not very sure - Did you try Ctrl + Click (Hot Lists)

3. setting an actual limit from within the popup - It was there in an earlier version, but I removed it. Since, the menu and action is now decided with modifier keys, I thought to hard code it. I will add it in the same code section bit.

4. Will add a check for that. (Currently, the error would come only if the script is invoked right after the cleanup is done. A tab change before invoking it will prevent it.)

5. The first time I checked that behavior, I only saw the pop-up from XY and thought it was informative and kept it that way. Somehow I missed the scripting dialog box which is annoying. I will add a check for that and the script would silently exit.

Next upload shouldn't take long.

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

Re: Clean Recent Menu

Post by nerdweed »

V2.1 is ready. Still facing an issue with Alt, the menu disappears on pressing alt (so codes 4-7) are mostly unusable.



Stef,
remove /* on line 7
remove */ on line 16
Comment line 70
remove /* on line 71
remove */ on line 79
Attachments
HitList.xys
(6.08 KiB) Downloaded 171 times

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

Re: Clean Recent Menu

Post by klownboy »

nerdweed wrote:Still facing an issue with Alt, the menu disappears on pressing alt (so codes 4-7) are mostly unusable.
Hi nerdweed I noticed that also. There's probably not much to do about it since the alt behavior is a Windows behavior. I'm happy though just being able to take advantage of shift, ctrl, and ctrl-shift. Thanks.

Edit: For initially bringing up various menus, alt in conjunction with shift or ctrl seem to work fine (e.g., right clicking in white space in tree or list). Most of the problems arise when you try to use alt to apply different actions to a menu item after the menu is displayed.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Stef123

Re: Clean Recent Menu

Post by Stef123 »

Many thanks nerdweed,

much better now, no more error messages. Setting the actual limit does not do anything. The dialog comes up, I enter "12" (without quotes) - but nothing changes, it remains at the default 32. After cleaning recent, it prompts me to enter a new value, which again, will not stick.
nerdweed wrote:Do you wish to see only the current drive. I don't think I would like that behavior
Me neither. A misunderstanding. I DO want to see other drives, but didn't in the earlier version. So it should have been possible from the start? Maybe I missed it or fooled myself. Anyway, it works now. Thanks.

BTW, what's the difference between Hotlist (Ctrl) and Hitlist (Ctrl Shift)?

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

Re: Clean Recent Menu

Post by nerdweed »

It appears you hadn't uncommented the inital code, anyways forget it. Revised version v2.2 follows

Since, you want to see all drives - I removed that bit of code. Also, I thought about keeping the option to allow changing the limit from within the menu, but I moved it to the very bottom.

If you would want it at top then

Code: Select all

Change
load "$CleanList<crlf>$PopUp", * , 's';
to
load "$PopUp<crlf>$CleanList", * , 's';
HotList is much like the official feature from Don (Ctrl+H) except that I have to generate it through script because the list isn't exposed directly. Second difference is that it doesn't show Recycle Bin (Probably it gets lost during path check but I didn't bother much about it)

The official feature (from the help file). Consider the paths to be navigated serially
Hotlist...

The Hotlist is a brand-new interface to your history, with the intention to present the history in a way that makes it as easy as possible to quickly go back to one of the places you have recently been -- as opposed to the traditional presentation of the history which makes it easy to go back and forth on your recent track.

The Hotlist is made like this:

(1) All its items are taken from the Recent Locations list.

(2) Computer and Network Places are removed (to keep it tight).

(3) It's ordered alphabetically.

(4) It's fresh: only existing paths are shown (the history can be outdated in this aspect).

(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, C:\Programs\XYplorer, and hence aren't interesting (or "hot") targets.

(6) It's grouped by separators, one section per drive.

Shortcut: Ctrl+H
HitList is a slight modification to it, basically in step 5. Let's say, if your history was like this
C:\
C:\Programs
D:\
D:\New Folder\
C:\Programs\XYplorer
Then
HotList will be shown as
D:\New Folder\
C:\Programs\XYplorer

HitList will be shown as
C:\Programs
D:\New Folder\
C:\Programs\XYplorer
HotList doesn't show non-leaf nodes considering them as a path to end up to the leaf node and hence of no importance in history.

On the other hand Hit-list will show non-leaf nodes if you had moved away to some other folder in between (treats it like as a pause of significance)
Attachments
HitList.xys
(5.78 KiB) Downloaded 172 times

Stef123

Re: Clean Recent Menu

Post by Stef123 »

nerdweed,
great explanation of hit vs hotlist. You made it crystal clear.

Sorry for not coming to grips with the (un)commenting of lines - probably my ignorance of syntax rules/ blanks/ whatever, wouldn't be the first time I struggle with it.

Thanks for the revised script. Actual limits works flawless now, also the sorted and grouped locations.
I do experience functional issues, though. Shift-clicking an entry does not move the selected item, but only goes to the location. Ctrl-clicking an entry brings up an error when two different drive letters are involved. To reproduce:
1) Go to D:\Tools
2) Go to C:\Users\...\Downloads\ or any C-Folder like AppData etc
3) select a file there, bring up any of your script menus, Ctrl click on D:\Tools
This will trigger an error, the location C:\Tools does not exist. It combines the drive of the current drive with the path of the destination. Instead of copying to the correctly listed D:\Tools it tries to copy to C:\Tools

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

Re: Clean Recent Menu

Post by nerdweed »

Great to hear that most stuff is resolved.
Stef123 wrote:Shift-clicking an entry does not move the selected item, but only goes to the location.
That's how it is supposed to.
nerdweed wrote:Whilst Invoking
Shift - Sorted menu
Ctrl - HotList
Ctrl+Shift - HitList
None/Others - Recent Menu


On Menu
Shift - Goto the selected item in new tab
Ctrl+Shift - Goto the selected item in other pane
Ctrl - Copies selected item to the clicked directory
Alt+Ctrl - Moves selected item to the clicked directory (Ctrl+Alt won't work nicely, because the menu won't be shown)
None/Others - Goto the selected item
Ctrl+Click is for copying. Due to the behaviour of Alt key, Alt+Ctrl doesn't seem to work always, so there isn't a sureshot way for move as the values 4-7 aren't very trustworthy. You can always change the values there
0 - No Modifier Keys
1 - Shift
2 - Ctrl
3 - Shift + Ctrl
4 - Alt
5 - Alt + Shift
6 - Alt + Ctrl
7 - Alt + Ctrl + Shift
Finally, the part where code is getting confused between drives. I must admit, I mostly work from a single drive and never checked that.

Try commenting out line 78 and it should fix that issue (My mind is occupied with something else currently, so won't be able to check that right now.)

Code: Select all

$loc = replace($loc, <xydrive>, "?:", , 1); //Portable tab
Let me know how it goes.

Stef123

Re: Clean Recent Menu

Post by Stef123 »

nerdweed wrote:
Stef123 wrote:Shift-clicking an entry does not move the selected item, but only goes to the location.
That's how it is supposed to.
:oops: - I was still stuck on your first intro. Reassigned Shift according to your guidelines and now moving via Shift works great. :tup:
nerdweed wrote: Finally, the part where code is getting confused between drives. I must admit, I mostly work from a single drive and never checked that.

Try commenting out line 78 and it should fix that issue
Yep. Without this line it works across drives. Many thanks nerdweed, for this very useful script. :beer:

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

Re: Clean Recent Menu

Post by nerdweed »

Perfect. Thanks Stef for testing it thoroughly. Just updating the same script after commenting that line.

Those who have commented that line, don't need to redownload.

V2.2.1
Attachments
HitList.xys
(5.79 KiB) Downloaded 179 times

Stef123

Re: Clean Recent Menu

Post by Stef123 »

Actual Limit is the only thing still unreliable, with Hotlist and Hitlist. Should be easy to reproduce by setting it to a low limit. What I get for Hitlist are incredibly long lists irrespective of my limit-settings.

Post Reply