It uses FileRead with the path in the window title of notepad++ and populates the content of the brackets in the active file you are on in notepad. It is supposed to create a new column after every 30 section titles and a blank <<>> bracket adds a gap in the menu to separate groups.
I use it for long documents, I can comment the tags out in a big ahk scripts, and It is really helpful for organizing my list of favorite bandcamp urls by genre.
I don't know much about writing code, but I found this script useful and some nice people in this forum helped me so I thought I would share The coding is far from perfect though.
It is probably way more convoluted and complicated than it needs to be, so if you try it and think it can be better, let me know!
here is the script:
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Global Brkt_f
Global Brkt_b
Brkt_f := "<" . "<"
Brkt_b := ">" . ">"
a::
NavigationWindow()
Gui, Show
return
GetNotepadDirect(){
NPDirect :=
WinGetTitle, NPDirect, A
StringTrimRight, NPDirect, NPDirect, 12
StringReplace, NPDirect, NPDirect, *
return NPDirect
}
GuiClose:
Gui Destroy
return
NavWndwBut:
WinActivate, %NMDirect%
Send, ^{End} ;go to bottom of document so section titles end up consistently at top of page when jumped to
Send, ^g ;notepad's go to line num
Send, % $Test := nLines(ArchiveContents, A_GuiControl) ;enter the appropriate line number
Send, {Enter}
Gui, Destroy
return
NavigationWindow(){
Global ArchiveContents
Global NMDirect
NMDirect :=
NMDirect := GetNotepadDirect() ;store path of active notepad file
FileRead, ArchiveContents, %NMDirect% ;get notepad file contents
StringReplace, ArchiveContents, ArchiveContents, `r`n, `n, All ;reformat for regexreplace to work
ArchiveContentSections := RegExReplace(ArchiveContents, "(^|" . Brkt_b . ").*?(" . Brkt_f . "|$)", "*")
StringTrimLeft, ArchiveContentSections, ArchiveContentSections, 1
StringTrimRight, ArchiveContentSections, ArchiveContentSections, 1
StringSplit, SxnName, ArchiveContentSections, *
NavPos :=
Loop, %SxnName0%
{
ColNum = 0
RowNum = 30
ColLimit := ColNum * RowNum
ColTop := ColLimit + RowNum
ntEffct := "p+60"
if (A_Index = Coltop)
{ ;top of additional columns
NavPos := "ym"
ColNum++
}
else if (A_Index > RowNum)
{ ;rest of additional columns
NavPos := "xp y+m"
}
if (SxnName%A_Index% = "") ;add separation in menu for blank brackets
Gui, Add, Text, %NavPos%,
else
Gui, Add, Button, gNavWndwBut %NavPos%, % SxnName%A_Index%
}
}
nLines(ArchiveContents, SectionName)
{
TheSectionName := "<" . "<" . SectionName . ">" . ">"
StringReplace, NewArchiveContents, ArchiveContents, %TheSectionName%, @, All
StringSplit, NewArchive, NewArchiveContents, @
StringReplace NewArchive1, NewArchive1, `n, `n, All UseErrorLevel
LineVar = %ErrorLevel%
LineNum := LineVar + 1
return LineNum
}
Code: Select all
<<Section1>>
Lorem ipsum dolor sit amet, vivamus mauris sed amet porttitor.
Libero nulla dolor facilisi scelerisque gravida et, sed non,
nec lorem sed inceptos egestas quidem, bibendum libero metus
non pellentesque. At eget. Magna metus magna, neque ut et
tincidunt dictum qui, sed natoque. Eleifend aenean augue imperdiet
sapien, facilisi enim dui in. Interdum morbi quia donec quis,
massa adipiscing volutpat. Ultrices tortor vel class eu. Felis
in pede elementum et tincidunt, lacus donec cras posuere, augue eu
viverra, lacinia diam leo nibh libero sollicitudin.
<<Section2>>
Facilisis vehicula, porta nam magna, ut lectus suspendisse risus
ac eget nec, quam massa porttitor, sociis vel. Faucibus mauris
amet, beatae vivamus lacus pretium, malesuada dapibus fringilla
id duis et ut. Aliquid a lobortis duis luctus pulvinar, amet
inventore pellentesque tincidunt non, duis ipsum suspendisse
sapien fusce sed nonummy, ante ut, dui augue quam euismod nulla
tristique eros. Metus placerat metus aliquet. Omnis eu.
Non magnis faucibus, integer amet vestibulum suspendisse, mattis
dolor vehicula lobortis, fringilla pellentesque.
<<>>
<<Section3>>
Tellus turpis natoque tincidunt pretium venenatis, fusce ante in
egestas a. Eleifend sollicitudin ut orci. Diam velit vulputate
nec, at a quisque varius sed ante. Arcu commodo varius condimentum.
Etiam mattis molestie, vitae sodales ac a, erat facilisis et elit
magna, tempus id felis aliquam consectetuer dictum morbi, nullam
vel nec. Et mi maecenas. Non ut at lorem. Consectetuer lacus
pede nullam tellus integer adipiscing, mollis aliquam egestas nisl
eu posuere, sit taciti. Ante faucibus sollicitudin nam sed, massa
consequat lectus nunc lectus, wisi erat blandit ac placerat
vehicula, lorem tempus id ullamcorper. Venenatis elit occaecati,
suscipit vitae metus in a.