Sign in to follow this  
Followers 0
Juggernaut

Random random's?

8 posts in this topic

#1 ·  Posted (edited)

I have 3 random declarations, and i am wondering, is there a way to randomize the Send() function?

Like if i have $letter1, $letter2, and $letter3, how can i make it so it sends one of those, at random?

Also: I have this script, and it only seems to run once, then it just spams text forever instead of completing the whole sequence, im not sure why.

;MOUSE X Y ---- 682 , 420
;START BUTTON - 507 , 504
sleep(1000)
HotKeySet("z","qt")
Func qt()
    Exit
EndFunc

Global $Letter, $num, $Letter2, $Letter3
While 1
    MouseClick("left",682,420)
    sleep(50)
    Send("{Backspace 10}")
    sleep(50)
Do
    $Letter = Chr(Random(Asc("A"), Asc("Z"), 1))
;$Letter2 = Chr(Random(Asc("a"), Asc("z"), 1))
;$Letter3 = Int(Random(0,9))
    send($letter)
    $num = $num + 1
Until $num = Int(random(7,9))
    MouseClick("left",507,504)
    WinWaitActive("Warning")
    Sleep(50)
    send("{Enter}")
    sleep(1500)
Wend
Edited by Juggernaut

Share this post


Link to post
Share on other sites



This?

Dim $letter[3]

$letter[0] = Chr(Random(Asc("A"), Asc("Z"), 1))
$letter[1] = Chr(Random(Asc("a"), Asc("z"), 1))
$letter[2] = Int(Random(0,9, 1))

Send($letter[Random(0, UBound($letter) - 1, 1)])

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Share this post


Link to post
Share on other sites

Ah..wonderful! Thank you :]

But also, how can I make it so that i fully repeats over and over? Right now, all it does is repeat once, and then it just keeps sending letters without stopping..

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Actually! I didnt fix it :{

After a few times it does it perfect, and then it goes back to just sending random text nonstop. or the program just closes..

This is what I have now.

;MOUSE X Y ---- 682 , 420
;START BUTTON - 507 , 504
sleep(1000)
HotKeySet("z","qt")
Func qt()
    Exit
EndFunc

Global $Letter, $num, $Letter2, $Letter3
While 1
    MouseClick("left",682,420)
    sleep(50)
    Send("{Backspace 10}")
    sleep(50)
Do
    Dim $letter[3]
    $letter[0] = Chr(Random(Asc("A"), Asc("Z"), 1))
    $letter[1] = Chr(Random(Asc("a"), Asc("z"), 1))
    $letter[2] = Int(Random(0,9, 1))
    Send($letter[Random(0, UBound($letter) - 1, 1)])
    $num = $num + 1
Until $num = Int(random(7,9))
    $num = 0
    MouseClick("left",507,504)
    WinWaitActive("Warning")
    Sleep(50)
    send("{Enter}")
    sleep(1500)
Wend
Edited by Juggernaut

Share this post


Link to post
Share on other sites

You should fix that Do-Until loop, using Random() as the ending condition can cause an infinite loop. Use a For-loop instead.

For $x = 1 to Random(7, 9, 1)
    MsgBox(0, "Count down!", $i)
Next

Also it's unnecessary to have Int() infront of every Random() since the third parameter in Random() gives integers when you set it to 1.

The Asc() is unnecessary too, it would be faster do directly use their numbers, see "ASCII Characters" in the helpfile or if you are lazy run:

MsgBox(0, "", Asc("A") & ":" & Asc("Z") & ":" & Asc("a") & ":" & Asc("z"))

Share this post


Link to post
Share on other sites

I want to as an infinite loop though. Just sometimes it stops and closes the program, or it just keeps pressing random keys and doesn't stop. It works a few times, and then messes up.

Share this post


Link to post
Share on other sites

Can anyone figure out why it just randomly stops and wont stop sending keys?

Share this post


Link to post
Share on other sites

Can anyone figure out why it just randomly stops and wont stop sending keys?

... because that is what you programed it to do :-)

You script sends the letter "z" at random times.

You coded the letter "z" to quit the script. :-)

try HotKeySet("{ESC}","qt")

This line of code is why the script "won't stop sending keys" at times.

Until $num = Int(Random(7, 9))

Each time thru your Do/Until loop, you increment $num by one...

...so, lets see how that gets evaluated when it hits the "Until" line.

$num = 4 and Int(Random(7, 9)) = 8

$num = 5 and Int(Random(7, 9)) = 7

$num = 6 and Int(Random(7, 9)) = 7

$num = 7 and Int(Random(7, 9)) = 8

$num = 8 and Int(Random(7, 9)) = 7

$num = 9 and Int(Random(7, 9)) = 8

$num = 10 and Int(Random(7, 9)) = 7

...continues until you kill the script or until AutoIt reaches its limits.

You might want to change this line from

Until $num = Int(Random(7, 9))

to

Until $num > Random(7, 9, 1)

Also this line from

$letter[2] = Int(Random(0,9, 1))

to

$letter[2] = Random(0,9, 1)


[size="1"][font="Arial"].[u].[/u][/font][/size]

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