Sign in to follow this  
Followers 0
confutatis

Validating user input

5 posts in this topic

Hello to all...

A newbie here who is building a GUI to help my users with repetitive tasks by using the SEND capability of AutoIT...

The user is first presented with a login screen. The user must enter a user name, a system password and another application password (we call it Varnet)...Now I want to make sure that the user enters something in each variable...How would I go about doing this...?

Here's a snippet of code from the script:

#include <GUIConstants.au3>
#include <file.au3>
#include <string.au3>
;
; Create the main GUI windows here, then switch to the login window
;
$ess_login=GuiCreate("Enprotech Steel Services, LLC.", 392, 263,(@DesktopWidth-392)/2, (@DesktopHeight-263)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$ess_main_menu=GuiCreate("Enprotech Steel Services, LLC.", 640, 480,(@DesktopWidth-640)/2, (@DesktopHeight-480)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

GUISwitch($ess_login)
GUISetState()

$v_user_label = GuiCtrlCreateLabel("Varnet username: ", 10, 30, 110, 20, $SS_RIGHT)
$s_password_label = GuiCtrlCreateLabel("System password: ", 10, 80, 110, 20, $SS_RIGHT)
$v_password_label = GuiCtrlCreateLabel("Varnet password: ", 10, 130, 110, 20, $SS_RIGHT)

$input_vuser = GuiCtrlCreateInput("", 130, 30, 58, 20, $ES_LOWERCASE)
GuiCtrlSetState($input_vuser, $GUI_FOCUS);start with cursor in this textbox
$input_spass = GuiCtrlCreateInput("", 130, 80, 120, 20, $ES_PASSWORD)
$input_vpass = GuiCtrlCreateInput("", 130, 130, 120, 20, $ES_PASSWORD)
GUICtrlSetLimit($input_vuser,3)


$ok_button = GuiCtrlCreateButton("OK", 30, 200, 120, 40)
    GuiCtrlSetState($ok_button, $GUI_DEFBUTTON)
$cancel_button = GuiCtrlCreateButton("Cancel", 240, 200, 120, 40)

while 1
    $msg = GuiGetMsg()
    
    Select
        
    case $msg=$GUI_EVENT_CLOSE or $msg=$cancel_button
        Exit
        
    case $msg=$ok_button
        $vuser=GUICtrlRead($input_vuser)
        $spass=GUICtrlRead($input_spass)
        $vpass=GUICtrlRead($input_vpass)
    ;$spass=_StringEncrypt(1,$spass,"ess4259")
    ;$vpass=_StringEncrypt(1,$vpass,"ess4259")
    ;$user_record=GUICtrlRead($vuser) & ":" & $spass & ":" & $vpass
    ;$user_file=_TempFile()
    ;_FileCreate($user_file)
    ;FileWrite($user_file,$user_record)
        exitloop
    EndSelect
WEnd

Thanks for all your help,

David

Share this post


Link to post
Share on other sites



first here is an example of a login/password script i just found

http://www.autoitscript.com/forum/index.php?showtopic=13047#

second here is a script for those " ...repetitive tasks... "

http://www.autoitscript.com/forum/index.php?showtopic=13024#

good luck

8)

<{POST_SNAPBACK}>

Problem with the first script is that it exits the program if the user hasn't done the right thing...I need to have the user "re-enter" the data so he can go on to the main menu section (which was not included with my code)...

David

Share this post


Link to post
Share on other sites

just change this one line

If $err Then Exit

to???

If $err Then return

????

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Problem with the first script is that it exits the program if the user hasn't done the right thing...I need to have the user "re-enter" the data so he can go on to the main menu section (which was not included with my code)...

David

<{POST_SNAPBACK}>

I will give that a shot and let you know...Thanks for the help.

David

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