Sign in to follow this  
Followers 0
pilky1986

Help with my script please

5 posts in this topic

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 :P

;-----------------

#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

;----------------

Share this post


Link to post
Share on other sites



If $Username = False And $Password = False Then

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

@pilky1986

Welcome to autoit forum :P

Please use code tags for display your scripts in the forum...

#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 by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Excellent thank you very much firefox! So simple when you know how :P 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 :unsure: . Do you ever use true and false.. or is it not recommended to ?

Share this post


Link to post
Share on other sites

@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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0