Fetch recently opened items and present in a toolbar menu

Discuss and share scripts and script files...
Post Reply
tedy
Posts: 323
Joined: 17 Jun 2009 21:48

Fetch recently opened items and present in a toolbar menu

Post by tedy »

I have a thread about Recent Documents functionality, and to some extent I'm happy (it adds opened documents in Windows' Recent Items submenu).
I can also add a User Button #1 and assign #156; as a script and it opens the Open... dialog where there is a dropdown with recently opened items.

The problem is there are also .exe files in the list and I want to filter these out. In a way I want a local and more customizable version of the recent items menu.
Could someone point some steps (as guidelines, even without scripts but i wouldnt mind some :) ) if this is possible - to fetch the last NN of the recently opened items, filter out the .exe entries, and show the list in a dropdown in a User Button in the toolbar, so I can open recent items with two clicks? For example the last 30 items, .exe's excluded.
Thanks.

highend
Posts: 14942
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Fetch recently opened items and present in a toolbar men

Post by highend »

Does XY store these entries in any of it's config files? If not you'll have a hard time to filter out all the superflous stuff inside
C:\Users\%UserName%\AppData\Roaming\Microsoft\Windows\Recent
...
One of my scripts helped you out? Please donate via Paypal

armsys
Posts: 557
Joined: 10 Mar 2012 12:40
Location: Hong Kong

Re: Fetch recently opened items and present in a toolbar men

Post by armsys »

highend wrote:Does XY store these entries in any of it's config files? If not you'll have a hard time to filter out all the superflous stuff inside
C:\Users\%UserName%\AppData\Roaming\Microsoft\Windows\Recent
...
Following Highend's post above, you may try out the following command in the AddressBar:

Code: Select all

C:\Users\%UserName%\AppData\Roaming\Microsoft\Windows\Recent?!.exe

tedy
Posts: 323
Joined: 17 Jun 2009 21:48

Re: Fetch recently opened items and present in a toolbar men

Post by tedy »

highend, I'm sure it keeps them somewhere in XY's data structure. This is proven by the File - Open... command where you can see a long log of opened items in the dropdown list. Windows' log keep only the last 15 items, and not .EXE files.
Maybe there is a way to read these items with a script, from some folder in xyplorer\data, then remove .exe entries and present them in a dropdown in a User Button's dropdown somehow.

armsys, to repeat - I'm not interested in Windows' Recent Itmes anymore when we talk about a local version - the idea is the local version to be more customizable, the log is already there (as seen in Open... dialog), just is it possible with current scripting to achieve my goal? That's the question - if it is, then I'll invest some time to learn the language and the commands. I won't mind if you point out which commands could help in this.
Thanks.

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

Re: Fetch recently opened items and present in a toolbar men

Post by admin »

Next beta will have something useful:

Code: Select all

    + SC get got a new named argument "list_recentlyopenedfiles".
      Syntax: get("list_recentlyopenedfiles", [separator=CRLF])
        [separator]:  String to place between items.
                      Defaults to CRLF (line feed).
        return:       List of recently opened files (as used in menu 
                      File | Open...).
      Examples:
        text get("list_recentlyopenedfiles");
        goto inputselect("Goto to any of the Recently Opened Files", get("list_recentlyopenedfiles"), <crlf>, 5);
        open inputselect("Open any of the Recently Opened Files", get("list_recentlyopenedfiles"), <crlf>, 5);

highend
Posts: 14942
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Fetch recently opened items and present in a toolbar men

Post by highend »

So you can use a simple command like:

Code: Select all

goto inputselect("Goto to any of the Recently Opened Files", formatlist(get("list_recentlyopenedfiles"), "ef", "<crlf>", "!*.exe"), "<crlf>", 5);
Which filters out all items that end on .exe.

If you still want to limit the list you'll have to use a foreach loop first.
E.g.:

Code: Select all

    $limitEntries = 30;

    $newItems = "";
    $fileList = formatlist(get("list_recentlyopenedfiles"), "ef", "<crlf>", "!*.exe");
    foreach($entry, $fileList, "<crlf>") {
        if ($i++ <= $limitEntries) {
            $newItems = $newItems . $entry . "<crlf>";
        }
    }
    goto inputselect("Goto to any of the Recently Opened Files", $newItems, "<crlf>", 5);
One of my scripts helped you out? Please donate via Paypal

armsys
Posts: 557
Joined: 10 Mar 2012 12:40
Location: Hong Kong

Re: Fetch recently opened items and present in a toolbar men

Post by armsys »

Highend, Thanks. :appl:

tedy
Posts: 323
Joined: 17 Jun 2009 21:48

Re: Fetch recently opened items and present in a toolbar men

Post by tedy »

highend, many thanks! :)
This will work in the future versions (beta etc.), right?

highend
Posts: 14942
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Fetch recently opened items and present in a toolbar men

Post by highend »

Sure, why not...
One of my scripts helped you out? Please donate via Paypal

tedy
Posts: 323
Joined: 17 Jun 2009 21:48

Re: Fetch recently opened items and present in a toolbar men

Post by tedy »

No, I meant this will work and require at least the versions that come after the current one, but I guess so, because Don said he will add this SC functionality in the next beta.
I found how to increase the start menu recent items' list size (to 30) using the group policy editor, so it is not so urgent for now.
But using scripting we'll be able to construct different algos to show only images, or archives or etc. in the last items to show and being able to reopen more easily when filtered.

RalphM
Posts: 2089
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Fetch recently opened items and present in a toolbar men

Post by RalphM »

Just be aware that the Recents of Windows include files opened by other means than XY as well, whereas XY's list is longer but limited to files openend from XY!
Ralph :)
(OS: W11 25H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)

tedy
Posts: 323
Joined: 17 Jun 2009 21:48

Re: Fetch recently opened items and present in a toolbar men

Post by tedy »

RalphM wrote:Just be aware that the Recents of Windows include files opened by other means than XY as well, whereas XY's list is longer but limited to files openend from XY!
Sure. This raises a question whether an Autohotkey script wouldn't be more appropriate. It could read the recent folder, filter if needed and display a GUI on the screen, using a hotkey.
I'm using AHK already for many years, to do some things in XY and other programs. For example Ctrl+MouseBack/Forward switches tabs more easily than Ctrl+(Shift+)Tab.

highend
Posts: 14942
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Fetch recently opened items and present in a toolbar men

Post by highend »

I don't see a reason to use AHK when XY can do it already...

E.g.:

Code: Select all

    $limitEntries = 0;
    $excludeExt = "|exe|library-ms|";

    $fileList = "";
    $recentEntries = listfolder("%appdata%\Microsoft\Windows\Recent", "*", 1, "|");
    foreach($entry, $recentEntries, "|") {
        if ($i == $limitEntries) {
            break;
        }
        $realPath = property("#LinkTarget", $entry);
        $realExt  = getpathcomponent($realPath, "ext");
        if ($excludeExt UnLikeI "*$realExt*") {
            if (exists($realPath) == 1) {
                $fileList = $fileList . $realPath . "<crlf>";
                $i++;
            }
        }
    }
    goto inputselect("Goto to any of the Recently Opened Files", $fileList, "<crlf>", 5);
One of my scripts helped you out? Please donate via Paypal

tedy
Posts: 323
Joined: 17 Jun 2009 21:48

Re: Fetch recently opened items and present in a toolbar men

Post by tedy »

Thanks, that is useful on its own.
But the idea was that with AHK you can invoke the recent items menu from anywhere, not only when you are working in XY and it has the focus.

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Fetch recently opened items and present in a toolbar men

Post by yusef88 »

highend wrote:So you can use a simple command like:

Code: Select all

goto inputselect("Goto to any of the Recently Opened Files", formatlist(get("list_recentlyopenedfiles"), "ef", "<crlf>", "!*.exe"), "<crlf>", 5);
Which filters out all items that end on .exe
how to add more filters !*.bat;!*.cmd;!*.com;!*.scr;!*.msi
-----------------
update: i added them like that "!*.exe", "!*.msi" and it works

Post Reply