sumit Posted July 13, 2007 Share Posted July 13, 2007 This code works great CODE #Include <GUiConstants.au3> ;Create GUI $Main = GUICreate('Welcome to MPT Broadband', 300, 100) Opt("GUICoordMode",1) $username = GUICtrlCreateInput('',100,20,100) $usernamelabel = GUICtrlCreateLabel('Username',30,23) $password = GUICtrlCreateInput('',100,45,100,0,$ES_PASSWORD) $passwordlabel = GUICtrlCreateLabel('Password',30,48) $Button_1 = GUICtrlCreateButton ("OK", 190, 70, 0, 0, 0x0001) $Button_2 = GUICtrlCreateButton ("Exit", 245, 70, 0, 0) GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $Button_1 GLOBAL $collectusername = GUICtrlRead($username) WinSetState('Collect Username and Password','',@SW_HIDE) GLOBAL $collectpassword = GUICtrlRead($password) MsgBox(0,'Username and Password','Username: ' & $collectusername & @CRLF & 'Password: ' & $collectpassword) ExitLoop Case $msg = $Button_2 Exit EndSelect Wend Can you please tell me ( Code would be appreciated ) how to save the username and password in an ini / text file and how to retrieve them from ini / text file Link to comment Share on other sites More sharing options...
Leighwyn Posted July 13, 2007 Share Posted July 13, 2007 (edited) FWIW this is copy/paste from the help fileIniRead ( "filename", "section", "key", "default" )$var = IniRead("C:\Temp\myfile.ini", "section2", "key", "NotFound")MsgBox(4096, "Result", $var)IniWrite ( "filename", "section", "key", "value" )IniWrite("C:\Temp\myfile.ini", "section2", "key", "this is a new value")myfile.ini would look something like...[section2]key=this is a new valueedit: edited for mr mcgee Edited July 13, 2007 by Leighwyn Link to comment Share on other sites More sharing options...
mikehunt114 Posted July 13, 2007 Share Posted July 13, 2007 Can you please stop posting new topics? All 3 of your topics are related....make one topic post. As for your request, create a checkbox, and then depending on the state of the checkbox, write to a file or not. #Include <GUiConstants.au3> ;Create GUI $Main = GUICreate('Welcome to MPT Broadband', 300, 100) Opt("GUICoordMode",1) $username = GUICtrlCreateInput('',100,20,100) $usernamelabel = GUICtrlCreateLabel('Username',30,23) $password = GUICtrlCreateInput('',100,45,100,0,$ES_PASSWORD) $passwordlabel = GUICtrlCreateLabel('Password',30,48) $Button_1 = GUICtrlCreateButton ("OK", 190, 70, 0, 0, 0x0001) $Button_2 = GUICtrlCreateButton ("Exit", 245, 70, 0, 0) $checkbox = GUICtrlCreateCheckbox("Save password", 10, 70) GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $Button_1 $check = GUICtrlRead($checkbox) GLOBAL $collectusername = GUICtrlRead($username) GLOBAL $collectpassword = GUICtrlRead($password) If $check = $GUI_CHECKED Then IniWrite("test.ini", "Data", "Username", $collectusername) IniWrite("test.ini", "Data", "Password", $collectpassword) EndIf WinSetState('Collect Username and Password','',@SW_HIDE) MsgBox(0,'Username and Password','Username: ' & $collectusername & @CRLF & 'Password: ' & $collectpassword) ExitLoop Case $msg = $Button_2 Exit EndSelect Wend Untested. IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font] Link to comment Share on other sites More sharing options...
MrCreatoR Posted July 13, 2007 Share Posted July 13, 2007 (edited) how to save the username and password in an ini / text file and how to retrieve them from ini / text file Well, after you exit the loop, you will need to write the ini file, and before vreating the gui you read the ini file, but also you might want to encrypt your password... expandcollapse popup#Include <GUiConstants.au3> #Include <String.au3> $IniFile = @ScriptDir & "\Test.ini" $ReadUserName = IniRead($IniFile, "Data", "User Name", "") $ReadUserPass = _StringEncrypt(0, IniRead($IniFile, "Data", "Password", ""), "0000", 2) ;Create GUI $Main = GUICreate('Welcome to MPT Broadband', 300, 100) Opt("GUICoordMode",1) $username = GUICtrlCreateInput($ReadUserName,100,20,100) $usernamelabel = GUICtrlCreateLabel('Username',30,23) $password = GUICtrlCreateInput($ReadUserPass,100,45,100,0,$ES_PASSWORD) $passwordlabel = GUICtrlCreateLabel('Password',30,48) $Button_1 = GUICtrlCreateButton ("OK", 190, 70, 0, 0, 0x0001) $Button_2 = GUICtrlCreateButton ("Exit", 245, 70, 0, 0) GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $Button_1 GLOBAL $collectusername = GUICtrlRead($username) WinSetState('Collect Username and Password','',@SW_HIDE) GLOBAL $collectpassword = GUICtrlRead($password) MsgBox(0,'Username and Password','Username: ' & $collectusername & @CRLF & 'Password: ' & $collectpassword) ExitLoop Case $msg = $Button_2 Exit EndSelect Wend IniWrite($IniFile, "Data", "User Name", $collectusername) IniWrite($IniFile, "Data", "Password", _StringEncrypt(1, $collectpassword, "0000", 2)) Edited July 13, 2007 by MsCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
sumit Posted July 13, 2007 Author Share Posted July 13, 2007 Thanks a lot buddies. You guys are genius. And Sorry for creating three different posts on same topic. Link to comment Share on other sites More sharing options...
dandymcgee Posted July 13, 2007 Share Posted July 13, 2007 (edited) Leighwyn - FWIW... What's that supposed to mean? Please take the time to type out words if you are going to use them in your reply (or use an abbreviation that is slightly more well-known). Thanks EDIT: Wow, my age does show throught every now and then. Lol just noticed he even added a link to the FWIW for the lazy ppl like me that can't type four letters into a google query... I PMed him an apology . BTW (By the way), this post isn't about my laziness... it's about sumit's question. Edited July 14, 2007 by dandymcgee - Dan [Website] Link to comment Share on other sites More sharing options...
sumit Posted July 13, 2007 Author Share Posted July 13, 2007 (edited) Can you please stop posting new topics? All 3 of your topics are related....make one topic post. As for your request, create a checkbox, and then depending on the state of the checkbox, write to a file or not. #Include <GUiConstants.au3> ;Create GUI $Main = GUICreate('Welcome to MPT Broadband', 300, 100) Opt("GUICoordMode",1) $username = GUICtrlCreateInput('',100,20,100) $usernamelabel = GUICtrlCreateLabel('Username',30,23) $password = GUICtrlCreateInput('',100,45,100,0,$ES_PASSWORD) $passwordlabel = GUICtrlCreateLabel('Password',30,48) $Button_1 = GUICtrlCreateButton ("OK", 190, 70, 0, 0, 0x0001) $Button_2 = GUICtrlCreateButton ("Exit", 245, 70, 0, 0) $checkbox = GUICtrlCreateCheckbox("Save password", 10, 70) GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $Button_1 $check = GUICtrlRead($checkbox) GLOBAL $collectusername = GUICtrlRead($username) GLOBAL $collectpassword = GUICtrlRead($password) If $check = $GUI_CHECKED Then IniWrite("test.ini", "Data", "Username", $collectusername) IniWrite("test.ini", "Data", "Password", $collectpassword) EndIf WinSetState('Collect Username and Password','',@SW_HIDE) MsgBox(0,'Username and Password','Username: ' & $collectusername & @CRLF & 'Password: ' & $collectpassword) ExitLoop Case $msg = $Button_2 Exit EndSelect Wend Untested. Can someone please tell me after entering username and password how to close the inputbox ( welcome to mpt broadband ) and then open messagebox ( username and password ) Edited July 13, 2007 by sumit Link to comment Share on other sites More sharing options...
RDSchaefer Posted July 14, 2007 Share Posted July 14, 2007 Leighwyn - FWIW... What's that supposed to mean? Please take the time to type out words if you are going to use them in your reply (or use an abbreviation that is slightly more well-known). ThanksFor What It's WorthNext time, do a little research before displaying your ignorance.Ralph Link to comment Share on other sites More sharing options...
Developers Jos Posted July 14, 2007 Developers Share Posted July 14, 2007 (edited) For What It's Worth ** Nothing...**Next time, do a little research before displaying your ignorance.... since this is not needed Ralph ..... Edited July 14, 2007 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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