Skip to content

Commit 6ca8141

Browse files
authored
Update HyperSearch.ahk
Added user-friendly CSV export
1 parent 201d8c9 commit 6ca8141

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

HyperSearch.ahk

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,9 @@ ButtonSubmit:
435435
} else if (UsrIn ~= "i)^export>cat.{0,5}") {
436436
GoSub, ExportCat
437437
GoSub, DestroyGui
438+
} else if (UsrIn ~= "i)^export>repo.{0,6}") {
439+
GoSub, ExportRepo
440+
GoSub, DestroyGui
438441
} else if (UsrIn ~= ".*\+.*"){
439442
GuiControl, -redraw, Link
440443
GoSub, AppendLinks
@@ -765,7 +768,53 @@ ExportCat:
765768
addLink .= "`n"
766769
}
767770
;MsgBox % index . "`n" . addLink
768-
FileAppend, %addLink%, %index%.csv
771+
newFile := index . ".csv"
772+
If FileExist(newFile) {
773+
FileDelete, %newFile%
774+
}
775+
FileAppend, %addLink%, %newFile%
776+
return
777+
778+
ExportRepo:
779+
Gui, Submit, noHide
780+
exportCell=
781+
repoTrim := SubStr(repo,1,-4)
782+
exportFile := repoTrim . "_Export.csv"
783+
If FileExist(exportFile) {
784+
FileDelete, %exportFile%
785+
}
786+
Loop % HSR_Array.MaxIndex()
787+
{
788+
exportArray := []
789+
exportCell := HSR_Array[A_Index,2]
790+
exportCat := HSR_Array[A_Index,1]
791+
exportCat := Trim(exportCat)
792+
exportCat := StrReplace(exportCat, ",", "")
793+
newPos:=1
794+
labelExportIndex:=1
795+
while (RegExMatch(exportCell, "O)\[(.*?)]", currentExportLabel, StartingPos := newPos) != 0) {
796+
newPos+=2
797+
RegExMatch(exportCell, "O)\((.*?)\)", currentExportLink, StartingPos := newPos)
798+
if (currentExportLink[1] != "*" && currentExportLink[1] != "" && currentExportLink[1] != " ") {
799+
expLink := currentExportLink[1]
800+
expLabel := currentExportLabel[1]
801+
expLabel := Trim(expLabel)
802+
expLink := Trim(expLink)
803+
expLabel := StrReplace(expLabel, ",", A_Space)
804+
expLink := StrReplace(expLink, ",", A_Space)
805+
exportArray[labelExportIndex,1]:=expLabel
806+
exportArray[labelExportIndex,2]:=expLink
807+
}
808+
newPos := currentExportLink.Pos(1)
809+
labelExportIndex++
810+
}
811+
Loop % exportArray.MaxIndex() {
812+
if (exportArray[A_Index,1] != "" && exportArray[A_Index,1] != " ")
813+
exportLinks .= exportCat . "," . exportArray[A_Index,1] . "," . exportArray[A_Index,2] . "`n"
814+
}
815+
;MsgBox % index . "`n" . addLink
816+
}
817+
FileAppend, %exportLinks%, %exportFile%
769818
return
770819

771820
FavButtonClick:

0 commit comments

Comments
 (0)