Jump to content

I know its simple but...


Recommended Posts

can someone guide me in the right direction. all I want to do is, when the username or password field is empty, a message box appears then returns to the user tp input window again. I only posted a snippet of my code since im only working on that part of it right now.

any help is greatly appreciated.

$pass=0
$pass = InputBox("Password", "Enter Password:", "", "*")
;$len_pass = StringLen(0) 
If $pass = "" Then
MsgBox(4096, "ISM Login", "Password in incorrect or blank")
Return 
EndIf
Link to comment
Share on other sites

Something like:

While 1 = 1
    $pass = InputBox("Password", "Enter Password:", "", "*")
    If $pass = "" Then
        MsgBox(4096, "ISM Login", "Password in incorrect or blank")
    Else
        ExitLoop
    EndIf
WEnd

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks. Works great! One last question, if the cancel key is clicked is their anything that can kill the whole script? or atleast quit/stop the script altogether?

Most of the functions return data as a return value or set @error. If you press Cancel InputBox sets @error=1 (according to the help file ;))

So your script would look like:

While 1 = 1
    $pass = InputBox("Password", "Enter Password:", "", "*")
    If @error = 1 Then Exit
    If $pass = "" Then
        MsgBox(4096, "ISM Login", "Password in incorrect or blank")
    Else
        ExitLoop
    EndIf
WEnd
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Most of the functions return data as a return value or set @error. If you press Cancel InputBox sets @error=1 (according to the help file :))

So your script would look like:

While 1 = 1
    $pass = InputBox("Password", "Enter Password:", "", "*")
    If @error = 1 Then Exit
    If $pass = "" Then
        MsgBox(4096, "ISM Login", "Password in incorrect or blank")
    Else
        ExitLoop
    EndIf
WEnd

Wow, it works perfect! I was looking thru the help files for about an hour or so today, thats how I how even begin to develop an idea of how the script should look. but Im still learning my way around the help files and with the whole scripting. Much Respect Water ;)
Link to comment
Share on other sites

Glad it works.

A good place to start learning AutoIt is the Wiki.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Same thing but 4 lines shorter ;)

Do
    $pass = InputBox("Password", "Enter Password:", "", "*")
    If @error = 1 Then Exit
    If $pass = "" Then MsgBox(4096, "ISM Login", "Password in incorrect or blank")
Until $pass <> ""
Link to comment
Share on other sites

Same thing but 4 lines shorter ;)

Do
    $pass = InputBox("Password", "Enter Password:", "", "*")
    If @error = 1 Then Exit
    If $pass = "" Then MsgBox(4096, "ISM Login", "Password in incorrect or blank")
Until $pass <> ""

Nice! Okay... so I wrote so more code for the string formatting. It halfway works, I think the format is correct but something just isnt right still. Would appreciate your help or anyone else's. Here is the user name & password portion of the code.

While 1 = 1
    $user = InputBox("Login", "Enter Username:")
    If @error = 1 Then Exit
    If $user = "" Then
    MsgBox(5, "ISM Login", "Please Enter User Name")
        Else
    ExitLoop
    EndIf
WEnd

$u_string = StringRegExp($user, "[:alnum:]|[:alpha][@][us][.][website][.][com]", 1)
If @error = 1 Then
    MsgBox(5, "ISM Login", "Please Check the format of the username" & @CRLF & "Example: username@us.ibm.com")
    Exit
    EndIf

While 1 = 1
    $pass = InputBox("Password", "Enter Password:", "", "*")
    If @error = 1 Then Exit
    If $pass = "" Then
        MsgBox(5, "ISM Login", "Password in incorrect or blank")
    Else
        ExitLoop
    EndIf
WEnd
Link to comment
Share on other sites

Nice! Okay... so I wrote so more code for the string formatting. It halfway works, I think the format is correct but something just isnt right still. Would appreciate your help or anyone else's. Here is the user name & password portion of the code.

$u_string = StringRegExp($user, "[:alnum:]|[:alpha][@][us][.][website][.][com]", 1)
If @error = 1 Then
    MsgBox(5, "ISM Login", "Please Check the format of the username" & @CRLF & "Example: username@us.ibm.com")
    Exit
    EndIf

Heya,

Your middle block of code (Quoted) will terminate if the username is not in the correct format. presumably you would prefer if the user had the option to re-enter the information? To do this, combine it with your initial loop.

Link to comment
Share on other sites

Heya,

Your middle block of code (Quoted) will terminate if the username is not in the correct format. presumably you would prefer if the user had the option to re-enter the information? To do this, combine it with your initial loop.

Correct. When I try to do that I'm still having a problem. It either take any format and goes to the next step or it continually loops if no username or password is entered but I still hit cancel it will not exit. Also the format does the samething depending on the arrangement of lines. Heres what I've come up with.

While 1 = 1
    $user = InputBox("Login", "Enter Username:")
    $u_string = StringRegExp($user, "[:alnum:]|[:alpha][@][us][.][ibm][.][com]", 1)
    If $u_string = 0 Then
    MsgBox(5, "ISM Login", "Please Check the format of the username" & @CRLF & "Example: username@us.ibm.com")
    Else
    EndIf
    If $user = "" Then
    MsgBox(5, "ISM Login", "Please Enter User Name")
        Else
    ExitLoop
EndIf
Do 
    Until $u_string = $user
WEnd



While 1 = 1
    $pass = InputBox("Password", "Enter Password:", "", "*")
    If @error = 1 Then Exit
    If $pass = "" Then
        MsgBox(5, "ISM Login", "Password in incorrect or blank")
    Else
        ExitLoop
    EndIf
WEnd
Link to comment
Share on other sites

Same thing but 4 lines shorter :)

Do
    $pass = InputBox("Password", "Enter Password:", "", "*")
    If @error = 1 Then Exit
    If $pass = "" Then MsgBox(4096, "ISM Login", "Password in incorrect or blank")
Until $pass <> ""

While InputBox("Password", "Enter password:", "", "*") <> "password"
    If @error = 1 Then Exit
    MsgBox(16, "ERROR", "Wrong / blank password, try again.")
WEnd

Another way. Sorry, I just had to. ;)

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

Here's with my final version looks like with the restrictions on the user name. Works perfectly. Feel free to use or comment.

; =================================================================================================
;                                           #UserName# 
; =================================================================================================
Do
    $user = InputBox("Login", "Enter Username:")
    If @error = 1 Then Exit
    If $user = "" Then MsgBox(16, "ISM Login", "Please Enter User Name")
    Until $user <> ""
    
$u_string = StringRegExp($user, "[a-z][0-9][@]{1}[u]{1}[s]{1}[.]{1}[i]{1}[b]{1}[m]{1}[.]{1}[c]{1}[o]{1}[m]{1}", 2)
If @error  Then
    MsgBox(5, "ISM Login", "Please Check the format of the username" & @CRLF & "Example: username@us.ibm.com")
    Exit
EndIf

; =================================================================================================
;                                           #Password# 
; =================================================================================================
Do
    $pass = InputBox("Password", "Enter Password:", "", "*")
    If @error = 1 Then Exit
    If $pass = "" Then MsgBox(16, "ISM Login", "Password in incorrect or blank")
    Until $pass <> ""
    
; =================================================================================================
;                                           #Ticket Numbers# 
; =================================================================================================
Do
$t_number = InputBox("Ticket Number", "Enter Ticket Number:" & @CRLF & "Example:C0000")
If @error = 1 Then Exit
If $t_number = "" Then MsgBox(16, "ISM Login", "Enter Ticket Number:")
Until $t_number <> ""

$t_string = StringRegExp($t_number, "[C](?i){1}[0-9]{4}", 1)
 If @error = 1 Then 
     MsgBox(5, "ISM Login", "Error in Ticket number")
     Exit
     EndIf
Edited by JayFran
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...