demandnothing Posted September 15, 2009 Share Posted September 15, 2009 (edited) including the GUI this is what i got: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 510, 206, 192, 124) GUISetBkColor(0x000000) $UserName = GUICtrlCreateInput("UserName", 88, 32, 305, 21) $PassWord = GUICtrlCreateInput("PassWord", 88, 88, 305, 21) $Button1 = GUICtrlCreateButton("Create", 184, 136, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 IniWrite("C:\myfile.ini", "section1", "key", $UserName) IniWrite("C:\myfile.ini", "section2", "key", $PassWord) EndSwitch WEnd but all i get is: [section1] key=3 [section2] key=4 Edited September 15, 2009 by demandnothing Link to comment Share on other sites More sharing options...
omikron48 Posted September 15, 2009 Share Posted September 15, 2009 (edited) GUICtrlCreateInput...Return ValueSuccess: Returns the identifier (controlID) of the new control. Failure: Returns 0. RemarksTo obtain the value of the control see GUICtrlRead.*Taken from help file*What you are storing inside $UserName and $PassWord are the control IDs, not the control value. Edited September 15, 2009 by omikron48 Link to comment Share on other sites More sharing options...
demandnothing Posted September 15, 2009 Author Share Posted September 15, 2009 that works.. thank you.. do you know how i would make it create a new line or key with each time the create button is hit? instead of replacing the old key values i need it to make a new key and value Link to comment Share on other sites More sharing options...
omikron48 Posted September 15, 2009 Share Posted September 15, 2009 (edited) You can make it like this: $section = 0 IniWrite("C:\myfile.ini", String($section), "username", $UserName) IniWrite("C:\myfile.ini", String($section), "password", $PassWord) Where $section is a counter you increment everytime create button is hit. Edited September 15, 2009 by omikron48 Link to comment Share on other sites More sharing options...
demandnothing Posted September 15, 2009 Author Share Posted September 15, 2009 (edited) ok.. how would i increment it as a counter? when i use it as u put it, the section is simply [0] and the key = whatever the password is set as EDIT: would i be able to use IniRead to find what the last set section was and base the $section to be that +1? Edited September 15, 2009 by demandnothing Link to comment Share on other sites More sharing options...
omikron48 Posted September 15, 2009 Share Posted September 15, 2009 (edited) A counter is just a variable used to count something. There's nothing special about it. Just stick this in the last part your code that handles the button click event. $section += 1 If the program is still running from the start when you IniRead, you can still use the value in $section to find out the latest section written in the file. Otherwise, you can use IniReadSectionNames to get an array of the section names inside your ini file, provided that all the sections have already been written to file. The last element of the array would be your latest section name. If you already have entries in the ini file before the script is run and want the counter to start from the last count of the ini file, you just use IniReadSectionNames and count the number of section names you have in the array. Edited September 15, 2009 by omikron48 Link to comment Share on other sites More sharing options...
evilelf Posted September 16, 2009 Share Posted September 16, 2009 'demandnothing' I've been working on something the same but ive gave up for the time being, Great news is ive found something that would work for us both. If you get yours working,Could you please show the results. - Thanks I just help another member in another topic for this You simply use my script to login There you set a username and password But we can modify it by creating a. Txt in internet expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3>; #include <EditConstants.au3> $Form1 = GUICreate("Login", 400, 250, -1, -1); begining of Login $PASSWORD = GUICtrlCreateInput("", 65, 167, 220, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL)) $ButtonOk = GUICtrlCreateButton("&OK", 200, 220, 75, 25, 0) $ButtonCancel = GUICtrlCreateButton("&Cancel", 280, 220, 75, 25, 0) $passwordlabel = GUICtrlCreateLabel("Password:", 8, 172, 50, 17) $usernamelabel = GUICtrlCreateLabel("Username:", 8, 143, 52, 17) $USERNAME = GUICtrlCreateInput("", 65, 144, 220, 21) GUICtrlCreateGroup('',10,2,380,100) GUICtrlCreateLabel('Terms of use of this Software',30,10,340,18) GUICtrlSetColor(-1, 0x0012FF) GUICtrlSetFont(-1,12,400) GUICtrlCreateLabel('To use this software to be Registered in Forum',30,28,340,18) GUICtrlSetFont(-1,12,400) GUICtrlCreateLabel('',30,46,340,18) GUICtrlSetFont(-1,12,400) GUICtrlCreateLabel('To open the program',30,64,340,18) GUICtrlSetFont(-1,12,400) GUICtrlCreateLabel('Team gOHc Thank you for your choice',30,82,340,18) GUICtrlSetFont(-1,12,400) GUICtrlCreateGroup('',-99,-99,1,1) GUICtrlSetBkColor(-1,0x000000) GUISetState(@SW_SHOW) While 1 $MSG = GUIGetMsg() Switch $MSG Case $ButtonOk If VerifyLogin(GUICtrlRead($USERNAME),GUICtrlRead($PASSWORD)) = 1 Then GUIDelete($Form1) MsgBox(-1,"Logado com Sucesso","Login Succ..") RunP() Else MsgBox(-1,"Error"," Username ou Senha está incorreto, Tente denovo") EndIf Case -3 Exit Case $ButtonCancel Exit EndSwitch WEnd Func VerifyLogin($USERNAME,$PASSWORD) If $USERNAME = "your user here" And $PASSWORD = "your pass here" Then Return 1 Else Return 0 EndIf EndFunc; End login Func Runp() ;Your Code begining here EndFunc Func onautoitexit() Exit EndFunc ;==>onautoitexit This is for modific in internet Func VerifyLogin($USERNAME,$PASSWORD) local $x = 1 Do inetget("http://yoursite.com/login.txt",@systemdir & "/login.txt") $login = filereadline(@systemdir & "/login.txt",$x) $string = stringsplit($login,"|") if $string[1] = $username and $string[2] = $password then return 1 exitloop Else $x = $x + 1 Endif if $login = "" then return 0 exitloop endif until $x = $x + 1 EndFunc Simply create a .Txt with the username and password user|pass1 user2|pass2 I hope I have helped Link to comment Share on other sites More sharing options...
demandnothing Posted September 16, 2009 Author Share Posted September 16, 2009 THATS PERFECT!! thank you very very much for posting this to me!! it also dawned on me that the file only has a call to download the file, and not one to remove it, so for safety sake put FileRemove(@systemdir & "/login.txt") before each Exit command, in the Functions and in the GUI Case's Link to comment Share on other sites More sharing options...
Mison Posted September 16, 2009 Share Posted September 16, 2009 I used much simpler approach in my Tray App List project.. a script that can add and remove application, stores the list of applications in List.ini.. what I did was.. save the items(app names) as key, not as value.. like this [app] Calculator.exe= Renamer.exe= PDFConverter.exe= instead of [app] key1="Calculator.exeCalculator.exe" key2="Renamer.exe" key3="PDFConverter.exe" Advantages: 1. No duplicate item. Old key will be replaced by new one if they have same name. 2. auto increment code is not needed anymore.. autoit will insert new key at the bottom of section(or replace existing in case of identical key name). Hi ;) Link to comment Share on other sites More sharing options...
demandnothing Posted September 16, 2009 Author Share Posted September 16, 2009 this is for a login script.. Link to comment Share on other sites More sharing options...
Mison Posted September 16, 2009 Share Posted September 16, 2009 (edited) I know.. I'm just sharing, it might help someday.. you could also store those data in this fashion.. [login] John=sdaerwrwr key= username, value=password.. require no auto increment ..or... [username] key1 = John [password] key1 = sdaerwrwr require auto increment code.. the possibilities are endless... Edited September 16, 2009 by Mison Hi ;) Link to comment Share on other sites More sharing options...
evilelf Posted September 16, 2009 Share Posted September 16, 2009 (edited) THATS PERFECT!! thank you very very much for posting this to me!! it also dawned on me that the file only has a call to download the file, and not one to remove it, so for safety sake put FileRemove(@systemdir & "/login.txt") before each Exit command, in the Functions and in the GUI Case's Yeah, I put mine righ after check, So it can be removed quickly. Case $ButtonOk If VerifyLogin(GUICtrlRead($USERNAME),GUICtrlRead($PASSWORD)) = 1 Then FileDelete(@SystemDir & "/login.txt") GUIDelete($Form1) MsgBox(-1,"Logado com Sucesso","Login Done, Thank You.") RunP() Glad I could help. Edited September 16, 2009 by evilelf Link to comment Share on other sites More sharing options...
demandnothing Posted September 16, 2009 Author Share Posted September 16, 2009 Yeah, I put mine righ after check, So it can be removed quickly. Case $ButtonOk If VerifyLogin(GUICtrlRead($USERNAME),GUICtrlRead($PASSWORD)) = 1 Then FileDelete(@SystemDir & "/login.txt") GUIDelete($Form1) MsgBox(-1,"Logado com Sucesso","Login Done, Thank You.") RunP() Glad I could help. that too.. but you need it especially in the Exit cases of the GUI, just incase they exit out or cancel it.. make sure people without accounts cant find them Link to comment Share on other sites More sharing options...
Mison Posted September 17, 2009 Share Posted September 17, 2009 This is an example of login + ini script.. $login = IniReadSection("login.ini","login") $user = InputBox("Welcome Guest", "Please enter your username:(Existing usernames:john,steve)") For $i=1 To $login[0][0] If $user = $login[$i][0] Then $pass = InputBox("Hi "&$user,"Now enter your password (correct password for "&$user&" = "&$login[$i][1]&")","","*") If $pass == $login[$i][1] Then MsgBox(0,"","Access Granted") Exit Else MsgBox(0,"","Sorry, wrong password") Exit EndIf EndIf Next MsgBox(0,"Opps..","Username not found, please register") it's cool... isn't it? login+ini.zip Hi ;) 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