pilky1986 Posted March 15, 2009 Share Posted March 15, 2009 Hello, i am completely new to using autoit and i am currently just creating pointless programs to learn the language. Ok basically i am trying to make a script that logs into my gmail account. There is a user interface for input of the username and password. My current problem is that i am trying to get my script to display a message i.e. You have not input a username and password.. when the "Go" button is pressed and the username and / or password box is blank. My problem is that i can not get my script to recognise that the values are blank i.e false when the button is pressed.. is this a problem with reading a variable created by GUICtrlCreateInput ?? My script is as follows.. any help is appreciated. Thanks ;----------------- #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <IE.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 316, 131, 193, 125) $Username = GUICtrlCreateInput("", 88, 24, 209, 21) $Password = GUICtrlCreateInput("", 88, 56, 209, 21,$ES_PASSWORD) $Label1 = GUICtrlCreateLabel("Username:", 24, 24, 55, 17) $Label2 = GUICtrlCreateLabel("Password:", 24, 56, 53, 17) $Button1 = GUICtrlCreateButton("Go!", 88, 88, 105, 33, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetData ($Username, "") GUICtrlSetData ($Password, "") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 if $Username and $Password = False Then msgbox(0,"Error","Both a Username and Password are required to continue") Elseif $username and $password = True then _IECreate("http://gmail.google.com") WinSetState("Google Mail - Windows Internet Explorer", "", @SW_MAXIMIZE) Send(GUICtrlRead($Username)) Send("{TAB}") Send(GUICtrlRead($Password)) ControlClick("Google Mail", "", "", "LEFT", "1", "1033", "260") EndIf EndSwitch WEnd ;---------------- Link to comment Share on other sites More sharing options...
foster74 Posted March 15, 2009 Share Posted March 15, 2009 If $Username = False And $Password = False Then Link to comment Share on other sites More sharing options...
FireFox Posted March 15, 2009 Share Posted March 15, 2009 (edited) @pilky1986 Welcome to autoit forum Please use code tags for display your scripts in the forum... expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <IE.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate('Form1', 316, 131, 193, 125) $Username = GUICtrlCreateInput('', 88, 24, 209, 21) $Password = GUICtrlCreateInput('', 88, 56, 209, 21, $ES_PASSWORD) $Label1 = GUICtrlCreateLabel('Username:', 24, 24, 55, 17) $Label2 = GUICtrlCreateLabel('Password:', 24, 56, 53, 17) $Button1 = GUICtrlCreateButton('Go!', 88, 88, 105, 33, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 If GUICtrlRead($Username) = '' And GUICtrlRead($Password) = '' Then MsgBox(16, 'Error', 'Both a Username and Password are required to continue') ElseIf GUICtrlRead($Username) = '' Then MsgBox(16, 'Error', 'Username is required to continue') ElseIf GUICtrlRead($Password) = '' Then MsgBox(16, 'Error', 'Password is required to continue') ElseIf GUICtrlRead($Username) <> '' And GUICtrlRead($Password) <> '' Then _IECreate('http://gmail.google.com') WinSetState('Google Mail - Windows Internet Explorer', '', @SW_MAXIMIZE) Send(GUICtrlRead($Username)) Send('{TAB}') Send(GUICtrlRead($Password)) ControlClick('Google Mail', '', '', 'LEFT', '1', '1033', '260') EndIf EndSwitch WEnd Cheers, FireFox. Edited March 15, 2009 by FireFox Link to comment Share on other sites More sharing options...
pilky1986 Posted March 15, 2009 Author Share Posted March 15, 2009 Excellent thank you very much firefox! So simple when you know how So basically to ready a variable from a gui you need to use the GUICtrlRead rather than just saying $variable = .. or whatever operator you are using. Thanks . Do you ever use true and false.. or is it not recommended to ? Link to comment Share on other sites More sharing options...
FireFox Posted March 15, 2009 Share Posted March 15, 2009 @pilky1986 I never use True or False for this things and I think its not for that and wont work... You can use True or False for variables, UDF etc... Cheers, FireFox. 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