Jump to content

Account Data Saver ( ini Read , ini Write problem)


Recommended Posts

Hello, i wanted to make a simple Accountdata Saver.

My Problem is , that im not able to Save the Acc Data correctly to the .ini and also i cant load them back to the accountdata saver.

Some help would be great.

Code:

;=>> Inclue <<=
#include
#include
#include

;=>> GUI/Code <<=
$Form1 = GUICreate("Accountdata", 600, 250)
$hListView = GUICtrlCreateListView("Portal|Username|Password", 0, 0, 600, 250)
;_GUICtrlListView_SetExtendedListViewStyle($hListView,$LVS_EX_FULLROWSELECT)

$Menue_Main = GUICtrlCreateMenu("Main Options")
$Menue_Main_1 = GUICtrlCreateMenuItem("Add", $Menue_Main)
$Menue_Main_2 = GUICtrlCreateMenuItem("Delete All", $Menue_Main)
$Menue_Main_Loading = GUICtrlCreateMenu("Load")
$Menue_Load_1= GUICtrlCreateMenuItem("Load from .ini", $Menue_Main_Loading)
$Menue_Main_Saveing = GUICtrlCreateMenu("Save")
$Menue_Save_1 = GUICtrlCreateMenuItem("Save to .ini", $Menue_Main_Saveing)

$Menue_ListView = GUICtrlCreateContextMenu($hListView)
$Menue_ListView_1 = GUICtrlCreateMenuItem("Delete", $Menue_ListView)
_GUICtrlListView_SetColumnWidth($hListView, 0, 200)
_GUICtrlListView_SetColumnWidth($hListView, 1, 200)
_GUICtrlListView_SetColumnWidth($hListView, 2, 200)

_GUICtrlListView_RegisterSortCallBack($hListView)

GUISetState(@SW_SHOW)

$IniName = "Daten.ini"
;[Sektion]
;Key = value

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Menue_Main_1 ;=>> Add ...
$portal = InputBox("", "Please enter the Portal you are registered at")
$username = InputBox("", "Please enter a Username you are registered with")
$password = InputBox("", "Please enter a Password you are registered with")
GUICtrlCreateListViewItem($portal & '|' & $username & '|' & $password, $hListView)
Case $Menue_ListView_1 ;=>> Delete
_GUICtrlListView_DeleteItemsSelected($hListView)
Case $Menue_Main_2 ;=>> Delete All
_GUICtrlListView_DeleteAllItems($hListView)
Case $Menue_Save_1 ;=>> Save 2 INI
$count_of_items = _GUICtrlListView_GetItemCount($hListView)
For $i = 0 To $count_of_items - 1 Step +1
IniWrite($IniName, "Portal", $i, $portal)
IniWrite($IniName, "Username",$i, $username)
IniWrite($IniName, "Password",$i, $password)


Next
Case $hListView
_GUICtrlListView_SortItems($hListView, GUICtrlGetState($hListView))
EndSwitch
WEnd

;=>> Function <<=
Func _ArraySow($array)
For $i = 1 To UBound($array) - 1 Step +1
MsgBox(0, "", $i & ":" & @CRLF & $array[$i])
Next
EndFunc ;==>_ArraySow

Link to comment
Share on other sites

You're not saving the contents of the ListView to the INI file, you're saving the same information just in different keys because you're using the variables holding the return from the input boxes. All you're ever going to get is the last value they hold. Changing this section of your code might do what you want.

Case $Menue_Save_1 ;=>> Save 2 INI
            $count_of_items = _GUICtrlListView_GetItemCount($hListView)
            For $i = 0 To $count_of_items - 1 Step +1
                IniWrite($IniName, "Portal", $i, _GUICtrlListView_GetItemText($hListView, $i, 0))
                IniWrite($IniName, "Username", $i, _GUICtrlListView_GetItemText($hListView, $i, 1))
                IniWrite($IniName, "Password", $i, _GUICtrlListView_GetItemText($hListView, $i, 2))
            Next

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Look at IniReadSection, that will allow you to know how many items are in each section, then you can loop through them to add them back into the LV with GUICtrlCreateListViewItem, basically do in reverse what I did to put them in there.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I tried it now like that , but i think its pretty wrong.

Case $Menue_Load_1 ;=>> Load from INI
$portal2=IniReadSection($IniName,"Portal")
IniRead($IniName, "Portal", $username2, GUICtrlCreateListViewItem($hListView, $portal2, 0))
$username2=IniReadSection($IniName,"Username")
IniRead($IniName, "Portal", $username2, GUICtrlCreateListViewItem($hListView, $username2, 0))
$password2=IniReadSection($IniName,"Password")
IniRead($IniName, "Portal", $username2, GUICtrlCreateListViewItem($hListView, $password2, 0))
Next
Edited by Hallistorm1989
Link to comment
Share on other sites

This might worked, it's untested, but should do what you're looking for.

Case $Menue_Load_1 ;=>> Load from INI
    $aPortal = IniReadSection($IniName, "Portal")
    $ausername = IniReadSection($IniName, "Username")
    $apassword = IniReadSection($IniName, "Password")
    For $I = 1 To $aPortal[0][0]
        GUICtrlCreateListViewItem($aPortal[$I][1] & "|" & $ausername[$I][1] & "|" & $ausername[$I][1], $hListview)
    Next

You'd probably have to add a _GUICtrlListView_DeleteAllItems before adding anything to the listview otherwise you'll get duplicate entries.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hello Guys ! I got one more problem , i tried to make a "password check system" But i dont know why it doesnt work , what did i do wrong ?

If FileExists("password.ini")Then
$Password= InputBox("Verification","Put your Password in here")
$apass=GUICtrlRead($Password)
$realpw=IniReadSection("password.ini","Password")
EndIf

If Guictrlread($Password)= $realpw Then
Launch()
Else
MsgBox(0,"Account Data Manager","The Password u used, wasnt the correct one !")
Exit
EndIf
If Not FileExists("password.ini")Then
$creationpsw=InputBox("Verification","Set your Password now!")
$npw=GUICtrlRead($creationpsw)
IniWrite("password.ini","Password2","1",$npw)
EndIf

Func Launch()
GUISetState(@SW_SHOW)
EndFunc
Edited by Hallistorm1989
Link to comment
Share on other sites

This:

$Password= InputBox("Verification","Put your Password in here")
$apass=GUICtrlRead($Password)
$realpw=IniReadSection("password.ini","Password")

If Guictrlread($Password)= $realpw Then

Is written wrong, InputBox returns the string entered into it. You can't then use GUICtrlRead on the return from it because it's not a control ID returned. To use that you'd need to check the $realpw variable against the string returned, not try to read from a non-existent control.

If $Password = $realpw Then

Even better would be to create a hash of the password and put that into the ini instead of the plaintext password. Search the forum for what that means. INI files have zero security for password storage because they're plaintext.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...