Recent Documents

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
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;

"string" - text argument (this must be enclosed in double quotes). If the argument is preceded by an 'a' (i.e., a"Argument") then it is converted from Unicode to ASCII before calling the API. (Some Windows APIs only accept ASCII arguments.)
Hope that this tip proves useful for others, as it has for me.

Joe
 
#2
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
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:
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?
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