Recent Items (Windows 7).
My Recent Documents (Windows XP).
Do notify of any issues.
[EDIT:] I fixed the VarSetCapacity issue, improved the script slightly, and made the script into a function.
Code: Select all
;e.g.
;q:: ;list recent files
vOutput := JEE_SysGetRecentItems("`r`n", 30, "F", vCount)
;vOutput := JEE_SysGetRecentItems("`r`n", 30, "FD", vCount)
;vOutput := JEE_SysGetRecentItems("`r`n", 30, "D", vCount)
Clipboard := vCount "`r`n" vOutput "`r`n"
MsgBox, % Clipboard
return
;vMode: 0(or F)/1(or FD/DF)/2(or D)=files/both/folders
JEE_SysGetRecentItems(vSep="`n", vMax=30, vMode=0, ByRef vCount="", vMustExist=1)
{
local vAttrib,vData,vDirRecent,vIsDir,vIsV1,vName,vNum,vOffset,vOutput,vPath,vTarget,vTemp
;CSIDL_RECENT := 8
VarSetCapacity(vDirRecent, 260*2, 0)
DllCall("shell32\SHGetFolderPath", Ptr,0, Int,8, Ptr,0, UInt,0, Str,vDirRecent)
vIsV1 := !!SubStr(1,0)
(vMode = "F") ? (vMode := 0) : ""
(vMode = "D") ? (vMode := 2) : ""
(vMode = "FD")||(vMode = "DF") ? (vMode := 1) : ""
vCount := 0
vOutput := ""
VarSetCapacity(vOutput, 260*2*vMax)
Loop, % vMax
{
RegRead, vData, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs, % A_Index-1
vTemp := ""
Loop, % Round(StrLen(vData) / 4)
{
vOffset := (A_Index*4)-3
vNum := Format("{:i}", "0x" SubStr(vData, vOffset+2, 2) SubStr(vData, vOffset, 2))
vTemp .= (vNum = 0) ? "|" : Chr(vNum)
}
vName := ""
Loop, Parse, vTemp, |
if (SubStr(A_LoopField, vIsV1-4) = ".lnk")
vName := A_LoopField
vPath := vDirRecent "\" vName
if !(vName = "") && FileExist(vPath)
{
FileGetShortcut, % vPath, vTarget
vAttrib := FileExist(vTarget)
if vMustExist && (vAttrib = "")
continue
vIsDir := InStr(vAttrib, "D")
if (vMode = 0 && !vIsDir) || (vMode = 1) || (vMode = 2 && vIsDir)
vOutput .= vTarget vSep, vCount += 1
}
}
return SubStr(vOutput, 1, -StrLen(vSep))
}