Jump to content

Match Input


Recommended Posts

Hello,

Is is possible to match the input given in a inputbox? For example: The answere is red, because thats a colour, but the user types only red, then it checks if the word matches with somewhere in the answere, if the word matches it displays a msgbox.

Link to comment
Share on other sites

Hello,

Is is possible to match the input given in a inputbox? For example: The answere is red, because thats a colour, but the user types only red, then it checks if the word matches with somewhere in the answere, if the word matches it displays a msgbox.

How about:

Dim $pass = "Bob"

do
$passwd = Inputbox("Password", "Input Password Here")


If $passwd = $pass then 
Msgbox(0,"Correct", "Access Granted")
Else
Msgbox(0, "Sorry", "WRONG!!")
Endif
Until $passwd = $pass

I hope that answers you Question

Sorry if i misunderstood

Link to comment
Share on other sites

That's a good way, but what I exsually meant is: Is it possible to match the input given in the inputbox with a programmed text. So if the answere is: "red, because thats a colour" and the user types only "red" than the access is also granted. If no word matched the access is denied

Link to comment
Share on other sites

  • Moderators

That's a good way, but what I exsually meant is: Is it possible to match the input given in the inputbox with a programmed text. So if the answere is: "red, because thats a colour" and the user types only "red" than the access is also granted. If no word matched the access is denied

Why don't you show what you've done thus far to try attempt it.

What is the scenerio that it would be Red as an answer, what situations would the user have to type that.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

That's a good way, but what I exsually meant is: Is it possible to match the input given in the inputbox with a programmed text. So if the answere is: "red, because thats a colour" and the user types only "red" than the access is also granted. If no word matched the access is denied

Oh! Ok i see,

Well, then modify the code like this maybe

Change

Dim $pass ="bob"

to

Dim $pass = "Bob is your brother"

Then in the do until loop

If StringInStr($passwd, $pass) Then

Edit:Sorry Smoke, didn't know you wanted to make him do it himself :">

Edited by Paulie
Link to comment
Share on other sites

HI,

I think this should work, but I would improve it to check for minimum 3 letters. :D

Dim $pass = "Bob is your brother"

$passwd = Inputbox("Password", "Input Password Here")

If StringInStr($pass, $passwd) <> 0 Then
    Msgbox(0,"Correct", "Access Granted")
    Else
    Msgbox(0, "Sorry", "WRONG!!")
Endif

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

now I got what you wanted to achieve. :D

Try this.

Dim $pass = "The answer is red"

Do
    Global $passwd = InputBox("Password", "Input Password Here")
Until $passwd <> " " And StringLen($passwd) >= 3

MsgBox(64, "First check()", check())

Func check()
    Local $found = False
    Local $passwodArray = StringSplit($passwd, " ")
    For $i = 1 To UBound($passwodArray) - 1
        If StringInStr($pass, $passwodArray[$i]) <> 0 Then
            $found = True
            ExitLoop
        EndIf
    Next
    If $found = True Then
        Return "Correct Access Granted"
    Else
        Return "Sorry WRONG!"
    EndIf
EndFunc   ;==>check

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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