-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathLV.ahk
67 lines (51 loc) · 1.54 KB
/
LV.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
-------------------------------------------------------------------------------------------------------------
LV.ahk
Useful ListView functions.
Note: No function is dependant upon another within this file.
-------------------------------------------------------------------------------------------------------------
*/
LV_SetDefault(sGUI, sLV){
GUI, %sGUI%:Default
GUI, ListView, %sLV%
return
}
LV_GetSel(){
return LV_GetNext(0, "Focused") == 0 ? 1 : LV_GetNext(0, "Focused")
}
LV_GetSelText(iCol=1){
iSel := (LV_GetNext(0, "Focused") == 0 ? 1 : LV_GetNext(0, "Focused"))
LV_GetText(sCurSel, iSel, iCol)
StringReplace, sCurSel, sCurSel, `r, , All ; Sometimes, characters are retrieved with a carriage-return.
return sCurSel
}
LV_GetAsText(iRow=1, iCol=1) { ; Too dangerous to use LV_GetText.
LV_GetText(sText, iRow, iCol)
return sText
}
LV_SetSel(iRow=1, sOptsOverride=""){
LV_Modify(0, "-Select") ; Unselect any selected.
LV_Modify(iRow, "Focus")
if (sOptsOverride)
LV_Modify(iRow, "Select " sOptsOverride)
else
LV_Modify(iRow, "Select Vis")
return
}
LV_SetSelText(sToSel, sOptsOverride="", iCol=1, bPartialMatch=false, bCaseSensitive=false){
Loop % LV_GetCount(){
LV_GetText(sThisCell, A_Index, iCol)
if (bCaseSensitive)
bExactMatch := (sThisCell == sToSel)
else bExactMatch := (sThisCell = sToSel)
if (bExactMatch || (bPartialMatch && InStr(sThisCell, sToSel))) {
LV_Modify(A_Index, "Focus")
if (sOptsOverride)
LV_Modify(A_Index, "Select " sOptsOverride)
else
LV_Modify(A_Index, "Select Vis")
return true
}
}
return false
}