Code: Select all
#Requires AutoHotkey v1.1.33
#NoEnv
#SingleInstance force
SetBatchLines, -1
TxtFile := A_ScriptDir . "\Soft.txt"
; FileRead, Content, %TxtFile%
; Generate test content >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Countries := ["Germany", "Greece", "Spain", "Syria", "United Kingdom", "USA"]
Content := ""
Loop, 10 {
Index := A_Index
For I, Country In Countries
Content .= Country . "`tValue " . Index . "`r`n"
}
; Remove the last line break
Content := RTrim(Content, "`r`n")
; Generate test content <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Create a line array
LineArr := StrSplit(Content, "`n", "`r")
Lines := LineArr.Length()
; Create te GUI
Gui, Add, Text, , Search:
Gui, Add, Edit, w400 vSearchTerm gSearch
Gui, Add, ListView, gGo grid xm w300 r25 x20 y100 -Multi Count%Lines% vmyList1, Column1|Column2
Gui, Add, StatusBar, , % " " . TotalItems . " of " . TotalItems . " Items"
Gui, Show, , ListView
GoSub, Search
Return
Go:
; whatever you want to do
MsgBox, ListView's label has been triggered!
Return
Search:
GuiControlGet, SearchTerm
GuiControl, -Redraw, myList1
LV_Delete()
Rows := 0
For I, Line In LineArr {
Cols := StrSplit(Line, "`t")
If (Searchterm = "") || InStr(Cols[1], SearchTerm)
Rows := LV_Add("", Cols*)
}
LV_ModifyCol(1, 100)
LV_ModifyCol(2, 100)
GuiControl, +Redraw, myList1
SB_SetText(" " . Rows . " of " . Lines . " Items")
Return
GuiClose:
ExitApp
?