Clean Recent Menu

Discuss and share scripts and script files...
LittleBiG
Posts: 1846
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: Clean Recent Menu

Post by LittleBiG »

klownboy wrote:(i.e., didn't update to my Recent Locations - it kept yours)
:shock: :biggrin: I have checked the xys and the code section, but I can't see my recent locations in it, so I hope others won't have this problem.

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

Re: Clean Recent Menu

Post by klownboy »

It was your initial attached file which had your recent locations at the end after the //separate line. I had looked at the code before running it and was wondering why they were there. In any case, when I ran the script, those locations only showed up when I had it initially assigned to the a right click. When I assigned it to a CTB left click, it updated to mine. When you updated the post and the attached file, I looked at the code again and noticed they were all gone (i.e., nothing after the //separate line). No big deal. Thanks again. It works great!
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

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

Re: Clean Recent Menu

Post by LittleBiG »

klownboy wrote:LittleBiG, very impressive and quite handy! :appl: I especially like your long replace line $sfile = replace($sfile,substr($sfile,strpos............................) I gave up trying to follow it through. :D
That was the price I had to pay not being familiar with regexp. But at the weekend I learnt some basics and I could shorten that line ridiculously:

Code: Select all

$sfile = RegExReplace($sfile, $limitlabel."\d+", $limitlabel.$new_limit, 1);

Stef123

Re: Clean Recent Menu

Post by Stef123 »

The more I use it, the more impressed I get. This is exactly what I was hoping for. Flawless in every environment, a great way to quickly navigate through foreign folder structures.

The only issue I have: On S: drives the key shortcut will change the sort order instead of taking me to the S-section. Good thing that A: drives are not around anymore :wink:

Is there a way to assign a key shortcut to the whole button/ dropdown list itself?
LittleBiG wrote: shorten that line ridiculously:

Code: Select all

$sfile = RegExReplace($sfile, $limitlabel."\d+", $limitlabel.$new_limit, 1);
Would it make sense for me to replace those lines? Not that I'd have any performance complaints or anything, just wondering.

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

Re: Clean Recent Menu

Post by LittleBiG »

There is no need to change that line. It is just interesting, showing the power of regexp. But to solve the keyboard issue, this can be a solution for you, as you prefer the letters to access the drives rather than the options:
CleanRecent.xys
(2.22 KiB) Downloaded 215 times
Ah, and the shortcut to the menu. Use the User/Manage commands menu, and create a new item, which looks like this (my hotkey is Alt+0):
2014-04-16_11h26_15.png
2014-04-16_11h26_15.png (48.19 KiB) Viewed 4462 times
Other solution can be to emulate the left click on your Clean Recent user button. In this case you should write this into the Script field:

Code: Select all

button "ctb20"
where you should change the number behind "ctb" to the number of your user button, which is assigned to the Clean Recent. (Mine is 20 as you can see.)

Stef123

Re: Clean Recent Menu

Post by Stef123 »

Hooray. It pops up right at my mouse pointer (as I hoped it would). :appl:
I knew how to assign a button to a user command. But couldn't figure it out the other way round :?, if the button already exists, but doesn't call a user command.

Thanks for the guidance. I am learning more from these examples than from the manual. Not because it were bad (it's not, on the contrary) but because I've been shirking everything *script*. Triggers painful memories :shock: (Java and other traumata)

This may be a good opportunity to start therapy on my script-phobia. None of the XY scripts have caused any damage on any of my systems (so far). Still baffles me how you pulled it off, but I sure would like to exercise the same kind of control - some day, hopefully. :roll:

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

Re: Clean Recent Menu

Post by LittleBiG »

Stef123 wrote:Thanks for the guidance.
You're welcome. :)
Stef123 wrote:This may be a good opportunity to start therapy on my script-phobia.
I strongly suggest to do so. In many cases, if you miss something from XY or you would like to do something more comfortable, a script will help you for sure. And they don't have to be big ones. My mostly used scripts are not longer than a few rows. So you can easily catch up with my knowledge :wink:

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

Re: Clean Recent Menu

Post by klownboy »

Hi, I really hope you don't mind LittleBiG, but I toyed with the CleanRecent script a little. It is excellent by itself as I mentioned earlier, but I thought why not combine it with both Favorite Files and Favorite Folders to get an even more useful script that should look something like this...
Recent Folders.PNG
Recent Folders.PNG (32.74 KiB) Viewed 4413 times
The only difficult part for me anyway was to single out any Favorite Folders which were Dual type displays. If you have any issues with the menu displaying the "bell" character shown above (made by pressing/holding alt and punching 007 on the numpad), substitute something else or delete it. Obviously, it works best and looks better if you have at least a few Favorite Folders and Favorite Files. You can check or make some in Tools | List Management. And no, the ones shown are not my favorites but I added them to see if this works.
Thanks again LittleBiG I really like the sorted view,
Ken
CleanRecent.zip
(1.08 KiB) Downloaded 207 times
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

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

Re: Clean Recent Menu

Post by LittleBiG »

klownboy wrote:Hi, I really hope you don't mind LittleBiG, but I toyed with the CleanRecent script a little.
The attachment CleanRecent.zip is no longer available
Of course I don't. This is not a continuously maintained script with version number, so feel free to use it as a base of your ideas and publish the outcome. By the way, I also prefer using less buttons, so if it is logical I come up with multi functional user buttons similarly to your solution. I also have already extended the script, but not with Favorite Files and Folders (which looks very good by the way), but the funcionality of copy and move the selected files to the recent locations. (the default is goto)
Attachments
CleanRecent with FileOps.zip
(1.07 KiB) Downloaded 201 times

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

Re: Clean Recent Menu

Post by klownboy »

Thanks LittleBiG, I tried your new update with the file operations. It worked great. When I get a chance I may try to meld my mod to your latest.

By the way, both your versions and my modified version seem to work just fine substituting "_Initialize" for "_loadrecent" for the script label in the cleanrecent.xys. This allows you to load the file in a normal way (e.g., simply load "CleanRecent.xys;" without calling out "_loadrecent"). As I noted earlier in the thread, it wouldn't work if you called out the script with the right click of a CTB, but it does work assigned to a CTB right click if you use "_Initialize" instead.

I'll have to take a look, I wonder if we could modify it further to take advantage of <get drop>, so we could drag and drop a file(s) onto the list?
Thanks again,
Ken
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

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

Re: Clean Recent Menu

Post by LittleBiG »

klownboy wrote:By the way, both your versions and my modified version seem to work just fine substituting "_Initialize" for "_loadrecent" for the script label in the cleanrecent.xys. This allows you to load the file in a normal way (e.g., simply load "CleanRecent.xys;" without calling out "_loadrecent").
Unfortunately it is not true. Because the script modifies itself, the first calling "_loadrecent" creates the appropriate xys file (overwriting the existing one) and the second (normal) load will display the resulted menu in the xys file. If you changed it to "_initialize", the previous state of recent locations would appear, not the latest one. Because "_initialize" would create the new xys, but it won't be seen because the previous one is already read into the memory. If I am not clear, try to think through what happens when you click the button. You will see, that only the second click on the button shows the desired menu.

By the way, this can probably be solved by creating a temporary file for the menu (clicking on the button creates the recent locations in the temporary xys, and then makes it appear.) But personally I don't like temporary files, so I wanted to invent a solution which can avoid using it.

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

Re: Clean Recent Menu

Post by klownboy »

LittleBiG wrote:Unfortunately it is not true. Because the script modifies itself...
Ok, I see exactly what you mean now. It only appeared to me that it worked since everything displayed, but it wasn't with the most up to date folder information, not until the next click. Thanks for straightening me out on that... I should have checked it out further.

I'm still not sure though why your originally specified line of: load "CleanRecent", "_loadrecent"; load "CleanRecent"; works fine in the normal left click assignment for a CTB but does not work with the right click assignment (i.e., the folders, if they are there initially they stay there, but are not updated). Though I think I've experienced or encountered this before when loading script labels on right click. Maybe it would work using a trigger, but it's probably not worth the time to investigate.
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 »

Bit late to jump in.

Modified the initial snippet to do without writing a temporary file or writing to itself(I try to avoid using temporary files)

Code: Select all

"MRU"
  $limit = 32;
  $count = 0;
  $sfile = """CLEAN RECENT""" . <crlf> . """-""" . <crlf>;
  foreach($recpath, get("list_recentlocations"), <crlf>,, "") {
    if ($count < $limit) {
      if (exists($recpath) > 0) {
      $sfile = $sfile . '"' . $recpath . "|*" . '"' . " goto " . '"' . $recpath . '"' . "<crlf>";
      $count++;
    }
  }
  }
  load $sfile,* , 's';
And the one with FileOperations which uses a Permanent Variable
Edit: Deleted due to some errors. Check http://www.xyplorer.com/xyfc/viewtopic. ... 30#p103466
Last edited by nerdweed on 24 Apr 2014 22:37, edited 1 time in total.

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

Re: Clean Recent Menu

Post by klownboy »

Thanks nerdweed for another rendition. It may be a bit more responsive probably because of the heredoc use as opposed to writefile. What do you think? I use the same technique for my most frequently used menu in XY. As it was in LittleBiG last version, it was quite easy to incorporate "Favorite Files" and "Favorite Folders" as shown in my post above simply by inserting those sections starting with the line "$FavCount = ..." to the "$FavFolders = ..." line in my version just before the "$MENU=<<<FOO" line.

Edit: Sorry , I forgot to mention you also have to modify the line $MENU=$MENU... which is right after the "FOO;" line to $MENU=$MENU . <crlf> . $ownrecent.$FavFiles.$FavFolders; Note this will also work with nerdweed's latest update posted on 24 April.
Thanks,
Ken
Last edited by klownboy on 25 Apr 2014 00:44, edited 1 time in total.
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 »

Yes, I think because of No Reading/Writing from/to the disk.

For some scripts that I plan to use very often - multiple times within a single session (stuff like this), I even add the code directly to the button rather than loading it as a script.

I had another CTB that opened Fav Folder on left click and Fav Files on right click. Your version is likely to replace that :biggrin:

Post Reply