AutoIt中的随机数不起作用

时间:2013-08-15 19:11:32

标签: random numbers autoit

此字符串的用意是以此格式生成随机数:l =字母n = num,

LLNNN

相反,它给了我这个:

NN

或者有时候:

N

代码

Local $destination = "C:\Users\Ryan\Pictures\Aurora.jpg"

If Random() < 1 Then
    $Lettera = Chr(Random(Asc("A"), Asc("Z")))
Endif
If Random() < 1 Then
    $Letterb = Chr(Random(Asc("A"), Asc("Z")))
Endif
If Random() < 1 Then
    $Numbera = Chr(Random(48, 57, 1))
Endif
If Random() < 1 Then
    $Numberb = Chr(Random(48, 57, 1))
Endif
If Random() < 1 Then
    $Numberc = Chr(Random(48, 57, 1))
Endif

SplashImageOn("Splash", $destination, 312, 146, 450, 300, 1)
Sleep(9000)
SplashOff()
If MsgBox(1, "code generator", "Create a new key?") = 1 Then
    msgBox(0, "code generator", "Your registry is:" + $Lettera + $Letterb + $Numbera + $Numberb + $Numberc)
EndIf

1 个答案:

答案 0 :(得分:0)

您可以将所有内容分配为字符串值,然后将其全部追加到最后。

Local $destination = "C:\Users\Ryan\Pictures\Aurora.jpg"

If Random() < 1 Then
    $Lettera = Chr(Random(Asc("A"), Asc("Z")))
Endif
If Random() < 1 Then
    $Letterb = Chr(Random(Asc("A"), Asc("Z")))
Endif
If Random() < 1 Then
    $Numbera = Chr(Random("48", "57", "1"))
Endif
If Random() < 1 Then
    $Numberb = Chr(Random("48", "57", "1"))
Endif
If Random() < 1 Then
    $Numberc = Chr(Random("48", "57", "1"))
Endif

SplashImageOn("Splash", $destination, 312, 146, 450, 300, 1)
Sleep(9000)
SplashOff()
If MsgBox(1, "code generator", "Create a new key?") = 1 Then
    msgBox(0, "code generator", "Your registry is:" & $Lettera & $Letterb & $Numbera & $Numberb & $Numberc)
EndIf