List all Notepad++ documents

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

List all Notepad++ documents

14 Apr 2018, 01:45

Hi, I'm wondering if anyone knows if it's possible to get a list of all documents (tabs) loaded into Notepad++?


I have some code that allows me to get a list of all Photoshop documents using COM, and was hoping I could just adjust the code to do the same in Notepad++, but so far I haven't found any way to interact with Notepad++ via COM.

Without COM, does anyone know if there's another way to get a list?
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: List all Notepad++ documents

14 Apr 2018, 02:15

Try this:

Code: Select all

;~ FileRead, xml, C:\Documents and Settings\%A_UserName%\Application Data	; for Win XP
FileRead, xml, C:\Users\%A_UserName%\AppData\Roaming\Notepad++\session.xml	; for Win 7
while RegExMatch(xml, "m`aiO)(?<=filename="")(.*)(?=""\s+back*)", num, A_Index = 1 ? 1 : num.Pos + num.Len)
	str .= num.value "`n"
msgbox % str
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: List all Notepad++ documents

14 Apr 2018, 02:25

the messagebox is blank - but I see where this code is going.


This is very close...
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: List all Notepad++ documents

14 Apr 2018, 02:34

Maybe if you manually open the xml file you can see the format and accomodate the regex to suit your needs.
This is my xml file which gave me the expected result.

Code: Select all

<NotepadPlus>
    <Session activeView="0">
        <mainView activeIndex="2">
            <File firstVisibleLine="0" xOffset="0" scrollWidth="870" startPos="108" endPos="108" selMode="0" lang="AutoHotkey" encoding="-1" filename="D:\Sorgenti\AutoHotKey\Scripts\Capslock_NEW.ahk" backupFilePath="C:\Users\Me\AppData\Roaming\Notepad++\backup\Capslock_NEW.ahk@2018-02-24_133123" originalFileLastModifTimestamp="1519463408" mapFirstVisibleDisplayLine="-1" mapFirstVisibleDocLine="-1" mapLastVisibleDocLine="-1" mapNbLine="-1" mapHigherPos="-1" mapWidth="-1" mapHeight="-1" mapKByteInDoc="6881280" mapWrapIndentMode="-1" mapIsWrap="no" />
            <File firstVisibleLine="3" xOffset="0" scrollWidth="28530" startPos="0" endPos="0" selMode="0" lang="XML" encoding="-1" filename="C:\Program Files\Notepad++\userDefineLang_AHK.xml" backupFilePath="" originalFileLastModifTimestamp="1519470161" mapFirstVisibleDisplayLine="-1" mapFirstVisibleDocLine="-1" mapLastVisibleDocLine="-1" mapNbLine="-1" mapHigherPos="-1" mapWidth="-1" mapHeight="-1" mapKByteInDoc="16776960" mapWrapIndentMode="-1" mapIsWrap="no" />
            <File firstVisibleLine="8299" xOffset="0" scrollWidth="72891" startPos="809198" endPos="809198" selMode="0" lang="Testo normale" encoding="-1" filename="D:\Sorgenti\AutoHotKey\Scripts\TraceBytes.exe" backupFilePath="" originalFileLastModifTimestamp="1321636664" mapFirstVisibleDisplayLine="-1" mapFirstVisibleDocLine="-1" mapLastVisibleDocLine="-1" mapNbLine="-1" mapHigherPos="-1" mapWidth="-1" mapHeight="-1" mapKByteInDoc="9812" mapWrapIndentMode="-1" mapIsWrap="no" />
        </mainView>
        <subView activeIndex="0" />
    </Session>
</NotepadPlus>
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: List all Notepad++ documents

14 Apr 2018, 02:54

thanks... let me look into this. My xml is very similar, it does indeed show the tabs which are open upon the most recent launching of Notepad++. I should be able to adjust the regex to get the titles.

I'm looking to build a listview which will show all of the tabs currently loaded into Notepad++, and then activate a particular tab when its corresponding title is clicked on inside the listview. I think this is probably a tall order but like I said, I have a Photoshop script which does just that, so I'm hoping to borrow from it to make this happen.

Don't know about you, but I hate the left-to-right tab titles at the top of a Notepad++ document, especially when say, 20 or more are loaded - which then requires you to click those small left/right arrow buttons to scroll that list horizontally - totally annoying. There should be a built in vertical list instead of those horizontal tab buttons. I know you can go to File/%documenttitle%, but I find that tedious as well - and, it doesn't show all titles if your current screen mode in Notepad++ is split horizontally (a few documents on the left pane, and a few more on the right pane)
Guest

Re: List all Notepad++ documents

14 Apr 2018, 17:09

scriptor2016 wrote:There should be a built in vertical list instead of those horizontal tab buttons.
Actually, there is:
Menu: Settings > Preferences > General tab : Enable Show Document List Panel
If the document list is not visible, drag the left border of the Notepad++ window to the right.
After selecting your document, you can drag to the left to hide it again.
Eureka
Posts: 65
Joined: 03 Apr 2018, 13:31

Re: List all Notepad++ documents

14 Apr 2018, 17:12

Guest wrote:
scriptor2016 wrote:There should be a built in vertical list instead of those horizontal tab buttons.
Actually, there is:
Menu: Settings > Preferences > General tab : Enable Show Document List Panel
If the document list is not visible, drag the left border of the Notepad++ window to the right.
After selecting your document, you can drag to the left to hide it again.
Sorry, forgot to log in ..
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: List all Notepad++ documents

14 Apr 2018, 21:07

oh man, thank-you Eureka!! That's exactly what I need!! Wasn't aware it was there
JiazeFelipeX
Posts: 1
Joined: 03 May 2019, 04:53

Re: List all Notepad++ documents

03 May 2019, 04:58

Odlanir wrote:
14 Apr 2018, 02:15
Try this:

Code: Select all

;~ FileRead, xml, C:\Documents and Settings\%A_UserName%\Application Data	; for Win XP
FileRead, xml, C:\Users\%A_UserName%\AppData\Roaming\Notepad++\session.xml	; for Win 7
while RegExMatch(xml, "m`aiO)(?<=filename="")(.*)(?=""\s+back*)", num, A_Index = 1 ? 1 : num.Pos + num.Len)
	str .= num.value "`n"
msgbox % str
The answer was correct, but there was a small mistake as the ternary operator in the while loop should read:

Code: Select all

A_Index == 1 ? 1 : num.Pos + num.Len
In other words, you forgot to use the equality operator, as you have used the assignment operator.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ShatterCoder and 135 guests