here I tried to make a > Listview with CSV-file : PRINT ADD DELETE MODIFY SEARCH
Code: Select all
;-------- 星期三 九月 2022-09-21 21:01 UTC --------------
;-
;- MODIFIED =
;- CREATED = 20220921
;- FILE = Listview: PRINT ADD DELETE MODIFY SEARCH
;-----------------------------------------------------
#Warn
#NoEnv
#SingleInstance force
Setworkingdir,%a_scriptdir%
SetBatchLines, -1
;--
SplitPath,a_scriptname, name, dir, ext, name_no_ext, drive
mainwindowtitle:=name_no_ext ;-- GUI-NAME
F1:= a_scriptdir . "\" . mainwindowtitle . ".txt" ;-- CSV-file
dlm:=";" ;-- DELIMITER
gosub,CreateTestFile
;--
Gui,1:Color,Black,Black
Gui,1:Font,S12 CYellow,Lucida Console
color=D4D0C8 ;- grayxxx
Gui,add,text ,x30 y10 , Use rightclick for MODIFY or DELETE
Gui, Add, ListView, background%color% cBlack grid x30 y45 w600 h560 vMLV1 gLVGO +altsubmit, Name|Fullpath
Gui, Add, Edit,x30 y625 w200 h27 -vscroll hWndHED1 vSRCH gSearch
SendMessage 0x1501, 1, "SEARCH Here",, ahk_id %hed1%
Gui, Add, Edit,x240 y625 w70 h27 -vscroll vTotal1 right
Gui,add,button,x400 y625 w100 h27 gADD , ADD_NEW
Gui,add,button,x520 y625 w90 h27 gPrint, PRINT
LV_ModifyCol(1,570),LV_ModifyCol(2,0)
Gui, Show,x100 y100 w650 h680,%mainwindowtitle%
;--------- if rightclick Listview Row ------------
Menu, CMenu, Add,
Menu, CMenu, Add, MODIFY , menuDo
Menu, CMenu, Add,
Menu, CMenu, Add,
Menu, CMenu, Add, DELETE , menuDo
Menu, CMenu, Add,
;----
Fill:
Gui,1:default
LV_Delete()
i:=0
GuiControl, -Redraw, MLV1
Fileread,var, *P65001 %f1%
for x,y in strsplit(var,"`n","`r")
{
if Y=
continue
row := []
loop, parse, y,%dlm%
row.push(a_loopfield)
i++
LV_add("",row*)
}
GuiControl, +Redraw, MLV1
Guicontrol,1:,total1,%i%
GuiControl,1:Focus,srch
Return
;=======================================
;-
;-----------------------------------
GuiClose:
ExitApp
;-----------------------------------
;-
;------------- MENU when rightclick on row ----------
menux:
if (rn=0)
return
MouseGetPos, musX, musY
Menu, CMenu, Show, %musX%,%musY%
return
;------------------------
menudo:
If (A_ThisMenuItem = "DELETE")
gosub,DELETEx
If (A_ThisMenuItem = "MODIFY")
gosub,MODIFYx
return
;============= END MENU ================
;-
;============= ADD_NEW =================
ADD:
Gui,1:submit,nohide
Gui,2:Font,S12 cBlack,Lucida Console
Gui,2:Add,Text, x1 y5 w80 , NAME
Gui,2:Add,Edit, x80 y5 w500 h27 vA21,
Gui,2:Add,Text, x1 y50 w80 , URL1
Gui,2:Add,Edit, x80 y50 w500 h27 vA22,
Gui,2:Add, Button,x550 y90 w50 h27, OK
Gui,2:Show, x2 y385 w620 h130, URL-INPUT
GuiControl,2:Focus,A21
return
;---------------------------------------
2GuiClose:
2GuiEscape:
Gui,2: Destroy
return
;--------------
2ButtonOK:
Gui,2:submit,nohide
if A21=
{
Gui,2: Destroy
return
}
FILEAPPEND, %A21%%dlm%%A22%`r`n,%F1%,utf-8
Gui,2: Destroy
GoSub,Fill ;- update LV
return
;=============== END ADD_NEW ================
;-
;=============== DELETE =====================
Deletex:
Gui,1:ListView,MLV1
cxx:="",RowNumber:=0,DeleteArray := []
Loop
{
RowNumber := LV_GetNext(RowNumber)
if not RowNumber
Break
LV_GetText(cx1,rownumber)
cxx .= cx1 . "`n"
DeleteArray[RowNumber] := "DEL"
}
msgbox, 262180,TEST ,Want you really DELETE ?`n%cxx%
ifmsgbox,NO
{
for index, in DeleteArray
LV_Modify(index, "-Select -Focus")
GuiControl,1:Focus,srch
return
}
;--------
cxx=
GuiControl, -Redraw, MLV1
for index, in DeleteArray
LV_Delete(index-A_Index+1)
GuiControl, +Redraw, MLV1
;---
listx=
ControlGet, Listx, List, , SysListView321,%mainwindowtitle%
stringreplace,listx,listx,`t,%dlm%,all
Filedelete,%f1%
fileappend,%listx%`r`n,%f1%,utf-8
listx:=""
GuiControl,1:Focus,srch
Return
;============= END DELETE ==================
;-
;============= MODIFY ======================
MODIFYx:
Gui,1:submit,nohide
Gui,1:ListView,MLV1
Gui,3:Font,S12 cBlack,Lucida Console
Gui,3:Add,Text, x1 y5 w80 , NAME
Gui,3:Add,Edit, x80 y5 w500 h27 vA31,%C1%
Gui,3:Add,Text, x1 y50 w80 , URL1
Gui,3:Add,Edit, x80 y50 w500 h27 vA32,%C2%
Gui,3:Add, Button,x550 y90 w50 h27, OK
Gui,3:Show, x2 y385 w620 h130, URL-INPUT
GuiControl,3:Focus,A31
return
;---------------------------------------
3GuiClose:
3GuiEscape:
Gui,3: Destroy
return
;--------------
3ButtonOK:
Gui,3:submit,nohide
FileRead,Filecontent, *P65001 %f1%
FileDelete, %f1%
StringReplace, FileContent, FileContent,%C1%%dlm%%C2%, %A31%%dlm%%A32%
FileAppend, %FileContent%`r`n, %f1%,UTF-8
filecontent=
Gui,3:destroy
Gosub,fill
return
;=============== END MODIFY =================
;-
;=============== SEARCH =====================
Search:
GuiControlGet,srch
Gui,1:ListView,MLV1
GuiControl, -Redraw, MLV1
LV_Delete()
i:=0
;--
row := []
for x,y in strsplit(var,"`n","`r")
{
if y=
continue
h:=StrSplit(y,dlm)
;hr:=h[1],mn:=h[2]
;if (InStr(h.1,srch) or InStr(h.2,srch)) ;- search in column-1 and in column-2
if instr(h.1,srch)
{
loop, parse, y, %dlm%
row.push(a_loopfield)
i++
LV_add("",row*)
row := []
}
GuiControl, +Redraw, MLV1
Guicontrol,1:,total1,%i%
}
;--
/*
;- search in all columns ---------
row := []
for x,y in strsplit(var,"`n","`r")
{
if instr(y,srch)
{
loop, parse, y, %dlm%
row.push(a_loopfield)
if y=
continue
i++
LV_add("",row*)
row := []
}
Guicontrol,1:,total1,%i%
}
*/
;---------------------------------
GuiControl, +Redraw, MLV1
if (srch="")
{
sleep,200
Guicontrol,1:,total1,%i%
}
Return
;-----------------------------------
;=============== END SEARCH =================
;-
;=============== PRINT ======================
PRINT:
fx:= a_scriptdir . "\" . mainwindowtitle . "_PRINTED.txt"
ifexist,%fx%
filedelete,%fx%
ControlGet, Listx, List, , SysListView321,%mainwindowtitle%
stringreplace,listx,listx,`t,%dlm%,all
fileappend,%listx%`r`n,%fx%,utf-8
listx=
try
run,%fx%
return
;================ END PRINT ================
;-
;-----------------------------------
LVGo:
Gui,1:default
Gui,1:ListView,MLV1
RN:=LV_GetNext("C")
if (rn=0)
return
Row := A_EventInfo
LV_GetText(C1,row,1)
LV_GetText(C2,row,2)
C2=%C2%
;--
if A_GuiEvent = Doubleclick
{
try
run,%C2%
}
;--
if A_GuiEvent = Rightclick
goto,menux
return
;-------------------------------------
;=============================================
CreateTestFile:
e2=
(Ltrim C join`r`n
British_pathe;https://www.youtube.com/channel/UCGp4u0WHLsK8OAxnvwiTyhA
BBC_Archive;https://www.bbc.co.uk/archive/
LA_CAMERA_STYLO;https://www.youtube.com/channel/UCxT4JLBXafKV7dCafIceCUg/videos ;- Film collection
Nikola Tesla Brings Light to Croatia;https://www.arte.tv/en/videos/105654-003-A/nikola-tesla-brings-light-to-croatia/
Nikola Tesla: niech stanie sie swiatlosc!;https://www.arte.tv/pl/videos/105654-003-A/nikola-tesla-niech-stanie-sie-swiatlosc/
News_Portugal;https://news.google.com/topstories?hl=pt-PT&gl=PT&ceid=PT:pt-150
Weather_Portugal;https://www.timeanddate.com/weather/portugal/lisbon
Calypso 我爱卡拉苏 - Grace Chang ( 葛蘭 - Ge Lan );https://www.youtube.com/watch?v=bi4f2E_1or4
)
ifnotexist,%F1%
fileappend,%e2%,%F1%,utf-8
e2=
return
;=========== END SCRIPT =====================================================================================================