Random Alpha-numeric character

Recommended Posts

```\$Number = Chr(Random(48, 57 ,1));--- ASCII Characters 0 to 9
\$Upper = Chr(Random(65, 90, 1));--- ASCII Characters A to Z
\$Lower = Chr(Random(97, 122, 1));--- ASCII Characters a to z
\$X = \$Number Or \$Upper Or \$Lower;--- ASCII Characters 0 to 9, A to Z, or a to z
MsgBox(0, "Random Alpha-Numeric Character", \$X)```

I want AutoIt to generate a random alpha-numeric character (numbers, upper case letters, lower case letters). However, I am having problem in my 4th line. What is the proper way of doing this?

Thanks!

Edited by totoymola

Share on other sites

A quick way; however, the distribution will not be exactly uniform (numbers would appear almost as frequently as letters):

```Dim \$array[3]
\$array[0] = Chr(Random(48, 57 ,1)); ASCII Characters 0 to 9
\$array[2] = Chr(Random(65, 90, 1)); ASCII Characters A to Z
\$array[1] = Chr(Random(97, 122, 1)); ASCII Characters a to z

\$X = \$array[Random(0,2,1)]
MsgBox(0, "Random Alpha-Numeric Character", \$X)```

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share on other sites

here's something from a couple of years ago, might help, might not

```MsgBox(0 , "Random Password", randompass("8"))

Func RandomPass(\$length)
If \$length < 9 then
For \$i = 1 To \$length
\$letter = Random(33, 126)
Next
Else
Return "Length too long"
Endif
Endfunc```

Don't argue with an idiot; people watching may not be able to tell the difference.

Share on other sites

```\$Number = Chr(Random(48, 57 ,1));--- ASCII Characters 0 to 9
\$Upper = Chr(Random(65, 90, 1));--- ASCII Characters A to Z
\$Lower = Chr(Random(97, 122, 1));--- ASCII Characters a to z
\$X = \$Number Or \$Upper Or \$Lower;--- ASCII Characters 0 to 9, A to Z, or a to z
MsgBox(0, "Random Alpha-Numeric Character", \$X)```

I want AutoIt to generate a random alpha-numeric character (numbers, upper case letters, lower case letters). However, I am having problem in my 4th line. What is the proper way of doing this?

Thanks!

Are you trying to do something like:
```Dim \$RandomChar[5]
\$RandomChar[1] = Chr(Random(48, 57, 1)); ASCII Characters 0 to 9
\$RandomChar[2] = Chr(Random(65, 90, 1)); ASCII Characters A to Z
\$RandomChar[3] = Chr(Random(97, 122, 1)); ASCII Characters a to z
\$RandomChar[4] = Random(1, 3, 1)
MsgBox(64, 'Info:', \$RandomChar[\$RandomChar[4]])oÝ÷ ØêÚºÚ"µÍÌÍÓ[XHÚ[ÛJ

MËJJNÈTÐÒRHÚXÝÈÈBÌÍÕHÚ[ÛJ
KLJJNÈTÐÒRHÚXÝÈHÈÌÍÓÝÙHÚ[ÛJMËLJJNÈTÐÒRHÚXÝÈHÈÌÍÖH  ÌÍÓ[X    [È ÌÍÕ  [È ÌÍÓÝÙÈTÐÒRHÚXÝÈÈKHÈÜHÈÙÐÞ
][ÝÔ[ÛH[KS[YXÈÚXÝ][ÝË   ÌÍÖ```
?

Edit:

Damn I'm slow!!

Edited by SmOke_N

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.

Share on other sites

Awesome! Im gonna test them all and see which will fit my needs. Thanks a lot guys.

Create an account

Register a new account