Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3>
#Region ### START Koda GUI section ### Form=
Global $ini_path = 'test.ini', $AccNumber
; check if ini file exists if not create it
;If $ini_path = '' Then _FileCreate("test.ini")
If Not FileExists($ini_path) Then
IniWriteSection("test.ini", "Account", "")
IniWriteSection("test.ini", "Password", "")
EndIf
$IniReadUser = IniReadSection($ini_path, "Account")
If @error <> 0 Then
$AccNumber = 0
Else
$AccNumber = $IniReadUser[0][0]
EndIf
; read items from ini in listview
GUICreate("Form1", 388, 596, 762, 289)
GUICtrlCreateGroup(" Add account", 8, 8, 369, 81)
GUICtrlCreateLabel("Username", 24, 32, 52, 15)
GUICtrlCreateLabel("Password", 153, 32, 50, 15)
$username = GUICtrlCreateInput("", 24, 50, 121, 21)
$password = GUICtrlCreateInput("", 152, 50, 121, 21)
$addAcc = GUICtrlCreateButton("Add", 288, 48, 75, 23)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup(" Accounts ", 8, 104, 369, 449)
$idListview = GUICtrlCreateListView("", 24, 136, 337, 396)
_GUICtrlListView_AddColumn($idListview, "Username", 150)
_GUICtrlListView_AddColumn($idListview, "Password", 183)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$startBtn = GUICtrlCreateButton("Start game", 8, 560, 369, 25)
_refreshListView()
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $addAcc
__addChar()
Case $idListview
;~ _GUICtrlListView_BeginUpdate($idListview)
;~ For $i = 1 To $dd[0][0]
;~ Local $dd = IniRead($ini_path, "Account", "test", "")
;~ _GUICtrlListView_AddItem($idListview, $dd, 1)
;~ Next
;~ _GUICtrlListView_EndUpdate($idListview)
EndSwitch
WEnd
; __runGame() runs game from list when u click double on item or select item start button
Func __runGame()
EndFunc ;=> __runGame()
; __addChar()
Func __addChar()
Local $user = GUICtrlRead($username)
Local $pass = GUICtrlRead($password)
If $user <> '' And $pass <> '' Then
$AccNumber += 1
IniWrite($ini_path, "Account", "User" & $AccNumber, $user)
IniWrite($ini_path, "Password", "Pass" & $AccNumber, $pass)
_refreshListView()
Else
MsgBox(64, "", "All fields must be filled.")
EndIf
EndFunc ;=> __addChar()
Func _refreshListView()
_GUICtrlListView_DeleteAllItems($idListview)
If $AccNumber = 0 Then
GUICtrlCreateListViewItem( "no data", $idListview)
Else
For $i = 1 To $AccNumber
GUICtrlCreateListViewItem(IniRead($ini_path, "Account", "User" & $i, "") & '|' & IniRead($ini_path, "Password", "Pass" & $i, ""), $idListview)
Next
EndIf
EndFunc