Im Making a Simple tray icon to run notepad++ and would like the context menu to show recently opened/closed items.
There is a list in np++ in the drop down file menu but i dont know how to retrieve them
Does anyone know if there's there a way to get a list of recently opened/closed np++ files?
Any help appreciated
Notepad++ Recently Opened List Topic is solved
Re: Notepad++ Recently Opened List
config.xml
Code: Select all
#Requires AutoHotkey v1.1.33
npp := "d:\utils\npp\notepad++.exe"
list := nppRecentFiles(npp)
For fileNum, filePath in list
MsgBox 0, % "File #" fileNum "/" list.Count(), % filePath
nppRecentFiles(npp) { ; Return array of file paths recently opened in Notepad++
pos := 0, list := []
SplitPath npp,, dir
If FileExist(xml := dir "\config.xml") {
FileRead txt, % xml
While pos := RegExMatch(txt, "filename=""(.+?)""", m, pos + 1)
list.Push(m1)
} Else MsgBox 48, Error, File not found.`n`n%xml%
Return list
}
Code: Select all
#Requires AutoHotkey v2.0
npp := "d:\utils\npp\notepad++.exe"
list := nppRecentFiles(npp)
For fileNum, filePath in list
MsgBox filePath, "File #" fileNum "/" list.Length
nppRecentFiles(npp) { ; Return array of file paths recently opened in Notepad++
pos := 0, list := []
SplitPath npp,, &dir
If FileExist(xml := dir "\config.xml") {
txt := FileRead(xml)
While pos := RegExMatch(txt, 'filename="(.+?)"', &m, pos + 1)
list.Push(m.1)
} Else MsgBox 'File not found.`n`n' xml, 'Error', 48
Return list
}
- Stinkfoot9
- Posts: 51
- Joined: 29 May 2022, 12:17
Re: Notepad++ Recently Opened List
Thank you... i swear i searched config.xml before but i guess not anyways your code works very good.
i came up with something also here's what i have so far and It works but it seems the config.xml file doesn't update every time you close/open a file, nothing i can do about that i don't think.
Code: Select all
OnMessage(0x404,"AHK_NotifyTrayIcon") ; https://www.autohotkey.com/board/topic/47840-updating-the-tray-menu-before-displaying-it/
AHK_NotifyTrayIcon(wParam, lParam) {
If (lparam = 517)
Gosub, ChangeMenu
}
ChangeMenu:
Menu,Tray,DeleteAll
Menu,Tray,NoStandard
menu,tray,add,Open,Open
menu,tray,add, Exit, Exit
Menu,tray,default,open
fr1()
Menu,tray,add, &%xxx5% ,xox5
Menu,tray,add, &%xxx4% ,xox4
Menu,tray,add, &%xxx3% ,xox3
Menu,tray,add, &%xxx2% ,xox2
Menu,tray,add, &%xxx1% ,xox1
return
xox1:
run, Notepad++.exe %xxx1%
return
xox2:
run, Notepad++.exe %xxx2%
return
xox3:
run, Notepad++.exe %xxx3%
return
xox4:
run, Notepad++.exe %xxx4%
return
xox5:
run, Notepad++.exe %xxx5%
return
open:
Run, Notepad++.exe
return
Exit:
Exitapp
return
return1:
return
fr1()
{
Fileread,xx,AppData\Roaming\Notepad++\config.xml
Loop,Parse,xx,`n
{
If a_index between 42 and 47
{
word_array := StrSplit(a_loopfield, """")
xlx .= word_array[2] "`n"
}
}
Loop,parse,xlx,`n
{
xxx%a_index% := """" A_loopfield """"
}
}
Check out my other scripts
Context Menu Clipboard History , Desktop image preview on hover , Cycle Win Taskbar tabs in order win11
Context Menu Clipboard History , Desktop image preview on hover , Cycle Win Taskbar tabs in order win11
Re: Notepad++ Recently Opened List Topic is solved
I did not run your script, but it looks like you are selecting specific line numbers, and I'm not sure why that would be a good idea.
You can insert my function into your script if you like.
You can insert my function into your script if you like.
Code: Select all
#Requires AutoHotkey v1.1.33
#Persistent
npp := "d:\utils\npp\notepad++.exe"
show := 5
ChangeMenu:
Menu Tray, DeleteAll
Menu Tray, Add
For fileNum, filePath in nppRecentFiles(npp) {
Menu Tray, Add, % filePath, Open
If (fileNum = show)
Break
}
Return
Open:
Run % npp " " A_ThisMenuItem
Return
nppRecentFiles(npp) { ; Return array of file paths recently opened in Notepad++
pos := 0, list := []
SplitPath npp,, dir
If FileExist(xml := dir "\config.xml") {
FileRead txt, % xml
While pos := RegExMatch(txt, "filename=""(.+?)""", m, pos + 1)
list.InsertAt(1, m1)
} Else MsgBox 48, Error, File not found.`n`n%xml%
Return list
}
Re: Notepad++ Recently Opened List
That's right, Notepad++ writes the configuration files when it exits.Stinkfoot9 wrote: ↑26 Jan 2023, 22:16i came up with something also here's what i have so far and It works but it seems the config.xml file doesn't update every time you close/open a file, nothing i can do about that i don't think.
Re: Notepad++ Recently Opened List
The Recent directory also contains LNK files pointing to recently accessed files.
Code: Select all
#Requires AutoHotkey v1.1.33
recent := A_AppData "\Microsoft\Windows\Recent"
Run % recent