Sign in to follow this  
Followers 0
RyGoTypE

Random Function.

20 posts in this topic

How would I exactly go about doing a random function with random amounts?

Example: I want to Send random letters a-z caps and non caps a random amount of times.

"saSADGTagwEddwDWdd"

"wdwDWd"

"erjtTJGgrgreGERgh"

Something like that?

Share this post


Link to post
Share on other sites



How would I exactly go about doing a random function with random amounts?

Example: I want to Send random letters a-z caps and non caps a random amount of times.

"saSADGTagwEddwDWdd"

"wdwDWd"

"erjtTJGgrgreGERgh"

Something like that?

loop

var &= Chr(Random(asc(), asc(), 1))


[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

loop

var &= Chr(Random(asc(), asc(), 1))

This is what I currently have.

ControlSend($handle, "", "", Chr(Random(Asc("a"), Asc("z"), 1)))

That is only sending a random lowercase letter one time. I would like it to send a mix of upper and lowercase randomly with a random amount of times.

"saSADGTagwEddwDWdd"

"wdwDWd"

"erjtTJGgrgreGERgh"

Something like that?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

This is what I currently have.

ControlSend($handle, "", "", Chr(Random(Asc("a"), Asc("z"), 1)))

That is only sending a random lowercase letter one time. I would like it to send a mix of upper and lowercase randomly with a random amount of times.

"saSADGTagwEddwDWdd"

"wdwDWd"

"erjtTJGgrgreGERgh"

Something like that?

I gave you the answer. Did you miss the "loop" part before controlsend() and holding the values in var?

Edit:

Global $sRanText
For $iCC = 1 To Random(5, 15, 1)
    Switch Random(1, 2, 1)
        Case 1
            $sRanText &= Chr(Random(Asc('a'), Asc('z'), 1))
        Case 2
            $sRanText &= Chr(Random(Asc('A'), Asc('Z'), 1))
    EndSwitch
Next
MsgBox(64, 'Info', $sRanText)
Edited by SmOke_N

[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

I took your code and made it so it would output for my needs and I still only get one lowercase letter.

Global $sRanText
For $iCC = 1 To Random(5, 15, 1)
    Switch Random(1, 2, 1)
        Case 1
            $sRanText &= Chr(Random(Asc('a'), Asc('z'), 1))
        Case 2
            $sRanText &= Chr(Random(Asc('A'), Asc('Z'), 1))
    EndSwitch
Next
ControlSend($handle, "", "", $sRanText)

Share this post


Link to post
Share on other sites

I took your code and made it so it would output for my needs and I still only get one lowercase letter.

Global $sRanText
For $iCC = 1 To Random(5, 15, 1)
    Switch Random(1, 2, 1)
        Case 1
            $sRanText &= Chr(Random(Asc('a'), Asc('z'), 1))
        Case 2
            $sRanText &= Chr(Random(Asc('A'), Asc('Z'), 1))
    EndSwitch
Next
ControlSend($handle, "", "", $sRanText)
What happens when you use raw mode? What are you doing anyway?

[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

I took your code and made it so it would output for my needs and I still only get one lowercase letter.

Global $sRanText
For $iCC = 1 To Random(5, 15, 1)
    Switch Random(1, 2, 1)
        Case 1
            $sRanText &= Chr(Random(Asc('a'), Asc('z'), 1))
        Case 2
            $sRanText &= Chr(Random(Asc('A'), Asc('Z'), 1))
    EndSwitch
Next
ControlSend($handle, "", "", $sRanText)
Try with this you'll see it works.

I prefered put the length in a var as I do'nt know how the compiler do with a function call in the upper limit of the For statement. Does it call the func each time or is smart enough to put it in a register?

Global $sRanText,$length
while 1
$length=Random(5, 15, 1)
For $iCC = 1 To $length
    Switch Random(1, 2, 1)
        Case 1
            $sRanText &= Chr(Random(Asc('a'), Asc('z'), 1))
        Case 2
            $sRanText &= Chr(Random(Asc('A'), Asc('Z'), 1))
    EndSwitch
Next
ConsoleWrite($sRanText & @CRLF)
$sRanText=''
Sleep(4000)
Wend

Share this post


Link to post
Share on other sites

I prefered put the length in a var as I do'nt know how the compiler do with a function call in the upper limit of the For statement.

[/autoit]

Always one way to find out. Also your loop doesn't address his issue with it only sending lower case (Unless he only tried it once, and that's what the Random chars produced), that's the only thing different other than the var as I presented.

[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

#10 ·  Posted (edited)

Always one way to find out. Also your loop doesn't address his issue with it only sending lower case (Unless he only tried it once, and that's what the Random chars produced), that's the only thing different other than the var as I presented.

The issue is that he is using after a send cmd which takes only the first char of the word

Excuse it's not true. I thought about hoykeyset

Otherwise, what do you mean with 'Always one way to find out.'?

Edited by tresa

Share this post


Link to post
Share on other sites

Try with this you'll see it works.

I prefered put the length in a var as I do'nt know how the compiler do with a function call in the upper limit of the For statement. Does it call the func each time or is smart enough to put it in a register?

Global $sRanText,$length
while 1
$length=Random(5, 15, 1)
For $iCC = 1 To $length
    Switch Random(1, 2, 1)
        Case 1
            $sRanText &= Chr(Random(Asc('a'), Asc('z'), 1))
        Case 2
            $sRanText &= Chr(Random(Asc('A'), Asc('Z'), 1))
    EndSwitch
Next
ConsoleWrite($sRanText & @CRLF)
$sRanText=''
Sleep(4000)
Wend

Even with the idea you have given me, it still only sends one lowercase letter.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

does it have to be unique ?

if not , then

$var = random()
$rand = _stringtohex($var)
msgbox(0,"",$rand &"There you go !")
Edited by WhiteTiger

Share this post


Link to post
Share on other sites

Even with the idea you have given me, it still only sends one lowercase letter.

to debug put a consolewrite statement just before controlsend to check $sRanText value

Otherwise, controlsend wait for a window title not an handle?And you do'nt specify a controlName

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Why not just use ControlSetText?

Edit:

And @tresa

"One way to find out"

Compile it and find out for yourself if you don't know what it will do.

Edit2:

@rygotype

Maybe look for ControlSendPlus() as well... you still haven't explained what you want this for, all I can think now is how I get these random names on my forum spam :whistle:

Edited by SmOke_N

[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

Global $handle = WinGetHandle("classname=GxWindowClassD3d")

Using Opt('WinTitleMatchMode', 4) as well I'm sure?

[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

AutoItSetOption("WinTitleMatchMode", 4)

Ok, so now we've played the cat and mouse game for 15 posts.

It's time (if you want an actual solution) to do the following:

1. Post a replication script that is similar to what you are currently doing (A working example, don't waste your time with anything else)

2. If there are 3rd party programs involved then provide what they are, links to them if they aren't common, or if it's browser based provide a link they can be interacted with properly.

3. If there are passwords involved, make a dummy account so that the issue can be tested on this end as well.

You asked a question, you received the answer, anything else is a guessing game. If you can't provide the information to us to help you, then you need to figure it out on your own.


[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

#include <Misc.au3>

$string=""
for $i=1 to Random ( 1,30,1 )
        $string&=_Iif ( random(0,1,1), chr(Random(65,90,1)), chr(Random(97,122,1)) )
Next
send($string,1)

I didnt quite follow some of the posts so i dont know if you already have the answer to your original question if so please ignore this post.

Share this post


Link to post
Share on other sites

Ive set a limit of 30 characters BTW you can simply change this

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