Hallistorm1989 Posted February 14, 2013 Share Posted February 14, 2013 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:expandcollapse popup;=>> 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 More sharing options...
BrewManNH Posted February 14, 2013 Share Posted February 14, 2013 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 Hallistorm1989 1 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 GudeHow 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 More sharing options...
Hallistorm1989 Posted February 14, 2013 Author Share Posted February 14, 2013 ty for that , was a great help for saving these inputs ! Could anyone else tell me how it will read the inifile and put the usernames , passwords , portal back in the list ? Link to comment Share on other sites More sharing options...
BrewManNH Posted February 14, 2013 Share Posted February 14, 2013 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. Hallistorm1989 1 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 GudeHow 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 More sharing options...
Hallistorm1989 Posted February 14, 2013 Author Share Posted February 14, 2013 (edited) 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 February 14, 2013 by Hallistorm1989 Link to comment Share on other sites More sharing options...
BrewManNH Posted February 14, 2013 Share Posted February 14, 2013 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. Hallistorm1989 1 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 GudeHow 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 More sharing options...
Hallistorm1989 Posted February 14, 2013 Author Share Posted February 14, 2013 Thank you very much for ur help , its working now ! Link to comment Share on other sites More sharing options...
Hallistorm1989 Posted February 15, 2013 Author Share Posted February 15, 2013 (edited) 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 February 15, 2013 by Hallistorm1989 Link to comment Share on other sites More sharing options...
Hallistorm1989 Posted February 15, 2013 Author Share Posted February 15, 2013 Still got the same problem. Link to comment Share on other sites More sharing options...
BrewManNH Posted February 15, 2013 Share Posted February 15, 2013 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. Hallistorm1989 1 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 GudeHow 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now