1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Recent Documents

Discussion in 'T&T - Scripting' started by Joe Caverly, Aug 30, 2009.

  1. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    680
    Likes Received:
    8
    While I use 4NT8, the following should work with later JPSoftware products.

    There are certain documents that I access almost everyday, which I like to open without having to hunt for them.

    Windows XP provides a list of recent documents by clicking Start, Documents. This list of Recent Documents, or sometimes called MRU (Most Recently Used) makes it very quick to open the documents that I use the most.

    Every evening, before I do my daily backup, I use Cache Cleaner, available from http://www.ccleaner.com, to remove unwanted files from my system.

    Cache Cleaner has an option to exclude the Recent Documents from being cleared, but in the course of a day, there are other documents that I create, which I will seldom access, so I allow Cache Cleaner to remove all Recent Documents from the MRU list.

    Every morning, one of the first programs that gets started on my system is 4NT8. One of the first things that 4NT8 does is to run 4start.btm.

    4start.btm is the logical place to call a batch file that will load the Recent Documents list with all of the documents that I access everyday.

    To load a document into the Recent Documents list from 4NT8, I do the following;

    Code:
    echo %@winapi[shell32,SHAddToRecentDocs,2,a"C:\Documents and Settings\jlc\My Documents\Yaris Fuel Milage.xlr"]
    echo %@winapi[shell32,SHAddToRecentDocs,2,a"C:\Documents and Settings\jlc\My Documents\Debt.xlr"]
    
    These are just two examples. You can add up to 15 items to the Recent Documents list in Windows XP. There is a way to increase the number of items in the Recent Documents list in Windows XP, but 15 is adequate for my needs.

    If you want to clear the Recent Documents list from 4NT8, the following will do just that,

    Code:
    echo %@winapi[shell32,SHAddToRecentDocs,2,0]
    
    Note in the call to add a document to the Recent Documents list, that I have an “a” before the path\filename.

    Here’s what the 4NT8 help file has to say about that;

    Hope that this tip proves useful for others, as it has for me.

    Joe
     
  2. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    680
    Likes Received:
    8
    Code:
    ::+-------------------------------------------------------------------
    ::| MRU.BTM
    ::|
    ::| Add items to the Most Recently Used list, or
    ::| Clear all items from the Most Recently Used List
    ::|
    ::| Microsoft Windows Vista Business
    ::| TCC 15.01.52
    ::| July 5, 2013
    ::| Joe Caverly
    ::|
    ::| Ref. http://jpsoft.com/forums/threads/recent-documents.1354/
    ::+-------------------------------------------------------------------
    @setlocal
    @echo off
    iff %# eq 0 then
      gosub Usage
      goto eoj
    endiff
    switch %1
    case add
      iff exist %2 then
        echo %@winapi[shell32,SHAddToRecentDocs,2,a%@truename[%2]] > nul
      else
        echo Could not find the file named %2
        goto eoj
      endiff
    case clear
      echo %@winapi[shell32,SHAddToRecentDocs,2,0] > nul
    default
      echo I do not know what %1 means.
      echo.
      gosub Usage
      goto eoj
    endswitch
    goto eoj:
    :eoj
    endlocal
    quit
     
    :Usage
    echo Usage: MRU add myfile.ext
    echo        MRU clear
    return
     
  3. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    Joe:
    The endlocal which follows quit is never actually executed, but quit (more exactly, exiting the batch program by its execution) forces an implied endlocal. Is that endlocal in your code to remind you that it is implied?
     
  4. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    680
    Likes Received:
    8
    I suppose it would be more proper to do

    Code:
    endlocal
    quit
    but yes, quit does force an implied endlocal. Desired result is achieved.

    Joe
     
  5. w_krieger

    Joined:
    Nov 2, 2008
    Messages:
    176
    Likes Received:
    0
    MRU works under Windows 2k as well. I copied the whole batch file into my batch repositary. thanks!
     

Share This Page