Code: Select all
#SingleInstance Force
ifexist, %A_ScriptDir%\Content1.txt
Fileread, Content1, %A_ScriptDir%\Content1.txt
ifexist, %A_ScriptDir%\Content2.txt
Fileread, Content2, %A_ScriptDir%\Content2.txt
Gui, Add, Tab3, x2 y0 w663 h378 +Buttons +0x8 AltSubmit vMyTab gMyTab, Tab1|Tab2
Gui, Tab, Tab1
Gui, Add, ListView, x152 y25 w480 h290 -multi LV0x1 vListViewContent1 gSelectionLV, Name|Surname|Birth Date
Gosub Fill1
Gui, Add, Edit, x12 y45 w130 h20 vName,
Gui, Add, Text, x12 y25 w130 h20, Name
Gui, Add, Text, x12 y75 w130 h20, Surname
Gui, Add, Edit, x12 y95 w130 h20 vSurname,
Gui, Add, Text, x12 y125 w130 h20, Birth Date
Gui, Add, Edit, x12 y145 w130 h20 vBirth,
Gui, Add, Button, x12 y175 w130 h40 gAdd, Add
Gui, Add, Button, x12 y225 w130 h40 gRemove, Remove
Gui, Tab, Tab2
Gui, Add, ListView, x152 y25 w480 h290 -multi LV0x1 vListViewContent2 gSelectionLV, Age|Size|Gender
Gosub Fill2
Gui, Add, Edit, x12 y45 w130 h20 vAge,
Gui, Add, Text, x12 y25 w130 h20, Age
Gui, Add, Text, x12 y75 w130 h20, Size
Gui, Add, Edit, x12 y95 w130 h20 vSize,
Gui, Add, Text, x12 y125 w130 h20, Gender
Gui, Add, Edit, x12 y145 w130 h20 vGender,
Gui, Add, Button, x12 y175 w130 h40 gAdd, Add
Gui, Add, Button, x12 y225 w130 h40 gRemove, Remove
Gui, ListView, ListViewContent1
Gui, Show, w664 h379, Untitled GUI
GuiControl, Focus, Name
return
MyTab:
GuiControlGet, MyTab
Gui, ListView, ListViewContent%MyTab%
return
Add:
; GuiControlGet, MyTab
Gui, Submit, NoHide
if (MyTab = 1)
LV_Add("", Name, Surname, Birth)
if (MyTab = 2)
LV_Add("", Age, Size, Gender)
return
Remove:
; Gui, ListView, ListViewContent%MyTab%
LV_Delete(LV_GetNext())
return
SelectionLV:
SelItem := LV_GetNext() ; get the number of the activated row
loop 3
Var%A_Index% = ; clearing the Variables to prevent wrong content while clicking not complete filled rows
LV_GetText(Var1, SelItem, 1) ; first column
LV_GetText(Var2, SelItem, 2) ; second column
LV_GetText(Var3, SelItem, 3) ; third column
if (SelItem < 1 || SelItem > LV_GetCount()) ; since we have stored LV_GetNext() into SelItem, we can use the variable instead of the function.
return
msgbox % Var1 " - " Var2 " - " Var3
return
GuiClose:
Loop 2
{
ControlGet, ListViewContent%A_Index%, List,, SysListView32%A_Index%
StringReplace, Content%A_Index%, Content%A_Index%, `r,, All ; to prevent storing data when nothing has changed
if !(ListViewContent%A_Index% = Content%A_Index%) ; to prevent storing data when nothing has changed
FileMove, %A_ScriptDir%\Content%A_Index%.txt, %A_ScriptDir%\Content%A_Index%_%a_now%.txt
}
Loop 2
{
if !(ListViewContent%A_Index% = Content%A_Index%) ; to prevent storing data when nothing has changed
Fileappend, % ListViewContent%A_Index%, %A_ScriptDir%\Content%A_Index%.txt, UTF-8
}
exitapp
return
Fill1:
Gui, ListView, ListViewContent1
Loop, parse, Content1, `n, `r
{
StringSplit, i_, A_LoopField, `t
LV_Add("", i_1, i_2, i_3)
}
return
Fill2:
Gui, ListView, ListViewContent2
Loop, parse, Content2, `n, `r
{
StringSplit, i_, A_LoopField, `t
LV_Add("", i_1, i_2, i_3)
}
return