Jump to content

Random Function.


 Share

Recommended Posts

  • Moderators

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))

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.

Link to comment
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?

Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
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)
Link to comment
Share on other sites

  • Moderators

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?

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.

Link to comment
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
Link to comment
Share on other sites

  • Moderators

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.

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.

Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
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

Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
Share on other sites

  • Moderators

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

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

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.

Link to comment
Share on other sites

  • Moderators

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.

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

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