Jump to content

Recommended Posts

Posted

Hey all,

I've scoured the forums for a few hours now (if this IS here, I'm sorry, but I could not find it)

I'm trying to create a script that will automatically run through the install of a security program (actually several), and to do it, I need the user to input the serial key up front. I know how to set a MAXIMUM character input, but how can I make it so that an error message pops-up whenever the user puts in FEWER than the required amount (20 digits)?

Any help would be greatly appreciated!

Thanks!

-Crowbar

Posted

Post the code you are working with so we can see it and help you.

My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]

Posted

Hi, and welcome!

  Quote

how can I make it so that an error message pops-up whenever the user puts in FEWER than the required amount (20 digits)?

You just need to check the lenght of returned value... something like that:

$sDefault = ""

While 1
    $sPass_Value = InputBox("Title", "Type password:", $sDefault, "*")
    If @error Then ExitLoop
    
    If StringLen($sPass_Value) < 20 Then
        MsgBox(48, "Error!", "Minimum password lenght is 20, please try again.")
        
        $sDefault = $sPass_Value
        ContinueLoop
    EndIf
    
    MsgBox(64, "", "Your password: " & $sPass_Value)
    
    ExitLoop
WEnd

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

*Sorry* I don't want to open a new thread. Is it possible to set a maximum number limit? I don't want error. For example, if the maximum number is 10 and you type 1 then the only number that can be entered is 0.

Posted

  Quote

Is it possible to set a maximum number limit?

As character numbers limit, yes, from the help file:

  Quote

The second and subsequent characters of the password field can be used to restrict input. Use a space to fill the first character to still see the characters typed. Putting an M after the first character indicates that input is Mandatory; i.e. you must enter something. Nothing will happen if you press the Ok button when there is nothing in the InputBox. It will not close and return the string.

You can also specify the maximum length in the end of the password field. Just enter a number as the last character to specify the length of the string.

$value = InputBox("Testing", "Enter the 1 or 2 character code.", "", " M10")

As for the character string limit (if i guess right, this is what you need), you will have to build a custom InputBox, and use GUIRegisterMsg to habdle the input.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted
  Quote

Is there anything else except of M (Mandatory)?

What do you need? you can read about all that this func have in the help flie.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

  Aassdd said:

Is there anything else except of M (Mandatory)?

Actually, yes. While researching the minimum, I found two ways (I'm sure there's quite a few out there, but...)

You can use the GUICtrlSetLimit() function to set a maximum limit for an input (Open the help file, go to index and type in "GUICtrlSetLimit" to read more and for an example script). You could ALSO, in theory at least, use the code that MsCreator posted, but using a Greater Than (>) instead of Less than (<), but that would pop-up a notification instead of just blocking further input. Ease of use: I would (and will be) going with M (Mandatory).

- Crowbar

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
  • Recently Browsing   0 members

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