Hi, this is the update.
Note: This code must be used on
AutoHotkeyU(UNICODE version of AutoHotkey)
since I couldn't get the icons from DllCall shell32.dll\SHGetFileInfo.
(It seems Vista's normal account can't use shell32.dll in DllCall. Maybe not but I've tried everything I found this couple days, nothing worked)
I'm not sure if icons will load in other Windows other than Vista too so
if you're not using Vista I'd appreciate it if you can report what happened.
-Added Delete Item/ Copy Path function
Btw, I am Mon, the original author of this script.
I made new account as Mon+ because I've lost the password to Mon account & I now use different e-mail I couldn't re-assign my password,
Below code has been updated to Newest Ver.
Code:
; Select menu item with Ctrl = Delete item from Recent & Menu
; Select menu item with Shift = Copy full path of selected item
; Select menu item with Ctrl + Shift = Copy name of selected item
; After running the script, Ctrl + P ( Change your hotkey in setting if you need to)
;======================================================
; Your Setting
;======================================================
TR_WhatType= .ahk,.txt ; File type which will show in the menu
TR_Hotkey= ^P ; ^ Ctrl + Shift ! Alt # Win (ex. Ctrl + Shift + A = ^+A )
TR_Check = 1 ; 1 will prompt on item delete. If you don't need prompt, 0
TR_Design := " ... " ; Basically ignore this one unless you need to change
;======================================================
; Main
;======================================================
if A_OSVersion in WIN_NT4,WIN_95,WIN_98,WIN_ME
{
; MsgBox This script requires Windows 2000/XP or later.
TR_RecentD := A_WinDir . "\Recent"
ExitApp
}
else if A_OSVersion in WIN_XP
{
TR_RecentD := RegExReplace(A_AppData, "Application Data$","")
TR_RecentD := TR_RecentD . "Recent"
}
else
TR_RecentD := A_AppData . "\Microsoft\Windows\Recent"
;MsgBox,%TR_RecentD%
Loop, parse, TR_WhatType,`,
{
RegRead, TR_OutputVar, HKEY_CLASSES_ROOT, %A_LoopField%
RegRead, TR_OutputVar, HKEY_CLASSES_ROOT, %TR_OutputVar%\DefaultIcon
if TR_OutputVar =
{
TR_Icon%A_Index% = shell32.dll
TR_Icon_no%A_Index% = 1
}
else
{
StringSplit, TR_OutputVar, TR_OutputVar,`,
TR_Icon%A_Index% := TR_OutputVar1
TR_Icon_no%A_Index% := TR_OutputVar2
}
}
TR_FileExist = 0
TR_FirstBuild = 0
Hotkey, %TR_Hotkey%,TR_SHOW
Gosub TR_CreateMenu
;======================================================
; Show if menu is not under build
;======================================================
TR_SHOW:
if TR_UnderBuild = 1
{
MsgBox,4096,TidyRecentAccessMenu,Creating Menu... Please Wait.
return
}
if TR_FirstBuild = 0
{
TR_FirstBuild = 1
return
}
Menu,TR_File,show
return
;=========================================
; Exectute / CopyPath / Delete item on select
;=========================================
TR_LinkRun:
TR_KeyState = 0
if GetKeyState("Shift")
TR_KeyState = 1
if GetKeyState("Ctrl")
TR_KeyState += 2
TR_Temp := RegExReplace(A_ThisMenuItem, TR_Design . ".*?$","")
if TR_KeyState = 1
{
FileGetShortcut,%TR_RecentD%\%TR_Temp%.lnk,TR_Path
clipboard := TR_Path
}
else if TR_KeyState = 2
{
if TR_Check = 1
{
msgbox,4100,TidyRecentAccessMenu,Do you wish to remove "%TR_Temp%" from recent?
IfMsgBox, Yes
{
filedelete,%TR_RecentD%\%TR_Temp%.lnk
Menu,%A_ThisMenu%,Delete,%A_ThisMenuItem%
}
}
else
{
filedelete,%TR_RecentD%\%TR_Temp%.lnk
Menu,%A_ThisMenu%,Delete,%A_ThisMenuItem%
}
}
else if TR_KeyState = 3
clipboard := TR_Temp
else
{
FileGetShortcut,%TR_RecentD%\%TR_Temp%.lnk,TR_Path,,TR_WF_Path
run %TR_Path%,%TR_WF_Path%,UseErrorLevel
if ErrorLevel
msgbox,4096,TidyRecentAccessMenu,Error on launching,This file extension type does not have any program assigned. `nPlease assign default program to run this extension.
}
return
;=========================================
; Create menu
;=========================================
TR_CreateMenu:
TR_UnderBuild = 1
TR_CNT = 0
TR_ListFile =
Loop, %TR_RecentD%\*.*,1
{
if A_LoopFileName = desktop.ini
continue
TR_ListFile = %TR_ListFile%%A_LoopFileTimeModified%`t%A_LoopFileName%`n
Sort, TR_ListFile, R ; Sort by date.
}
Loop, parse, TR_ListFile, `n
{
if A_LoopField = ; Omit the last linefeed (blank item) at the end of the list.
continue
StringSplit, TR_ItemPath, A_LoopField, %A_Tab%
FileGetShortcut,%TR_RecentD%\%TR_ItemPath2%,TR_Path
IfNotExist, %TR_Path% ; Delete link if actual file is re/moved
{
filedelete,%TR_RecentD%\%TR_ItemPath2%
continue
}
StringTrimRight,TR_Name,TR_ItemPath2,4
SplitPath,TR_Path,,TR_Path,TR_Whatisit
if TR_Whatisit =
{
TR_FolderExist = 1
Menu,TR_Folder,add,%TR_Name%%TR_Design%%TR_Path%,TR_LinkRun
Menu,TR_Folder,Icon,%TR_Name%%TR_Design%%TR_Path%,shell32.dll,4
}
else if TR_ItemPath2 contains %TR_WhatType%
{
TR_FileExist = 1
Menu,TR_File,add,%TR_Name%%TR_Design%%TR_Path%,TR_LinkRun
Loop, parse, TR_WhatType,`,
{
TR_Whatisit := "." . TR_Whatisit
if TR_Whatisit contains %A_LoopField%
{
TR_OutputVar1 := TR_Icon%A_Index%
TR_OutputVar2 := TR_Icon_no%A_Index%
Menu,TR_File,Icon,%TR_Name%%TR_Design%%TR_Path%,%TR_OutputVar1%,%TR_OutputVar2%
}
}
}
}
if TR_FileExist = 1
Menu,TR_File,add,
Menu,TR_File,add,Refresh,TR_ReCreateMenu
Menu,TR_File,Icon,Refresh,shell32.dll,81
if TR_FolderExist = 1
{
Menu,TR_File,add,
Menu,TR_File,add,Folder,:TR_Folder
Menu,TR_File,Icon,Folder,shell32.dll,4
}
Sleep 500
TR_UnderBuild = 0
return
;=========================================
; ReCreate menu
;=========================================
TR_ReCreateMenu:
Menu,TR_File,Delete
if TR_FolderExist = 1
Menu,TR_Folder,Delete
Gosub TR_CreateMenu
Gosub TR_Show
return