Sign in to follow this  
Followers 0
PcExpert

Match Input

9 posts in this topic

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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

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.


[center]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.[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

It doesn't work :D

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

OK, thanks! It's a step in the good way. But if I now run it, it only checks for one word that matches. How to extend it?

Once again, Thanks

PcExpert

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

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