random typer

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

random typer

Post by idiot » Fri Apr 20, 2007 8:41 pm

how would i make a simple script that would randomly type a word using a set list of characters that i set and how could i set it to make the word only of length 0-20 :?:
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Apr 20, 2007 9:14 pm

Do you need a WORD to be real word found in a dictionary of your language, or is any group of characters be considered a word? A length of zero is really acceptable?

Do each of the next 9 lines contain legitimate words?
this
is
really

good
abcdds
ccdddrrt
kjkk
general
------------------------------------------------
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

words

Post by idiot » Fri Apr 20, 2007 9:21 pm

any group of characters is considered a word well guess i should make it 1-20 instead of 0-20 oh and could i also use space as a character?i wanted to create something similiar to that using all numbers letters and space bar as charcaters but i want it make the word random im not wanting to make a list i just want it to type one random word so each time it types its random
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Apr 20, 2007 11:14 pm

So you want a random string of characters, length from 1-20 inclusive.
Accepatable characters include and are limited to:
letters a-z, numbers 0-9, space character.

include uppercase and/or uppercase?

If only allow one case, then have a total of 37 characters = CharCount
or
If allow both cases, then have a total of 63 characters = CharCount

Here is an outline to code for 63 chars:
-------------------------------------------------------
Make a string a-z,A-Z,space,0-9 = CharMembers.

Select a random number 1-20 for WordLength
Make a loop to cycle WordLength times
In the loop
Select a random number 1-CharCount
Concatenate Word by adding CharCount position of CharMembers
Increment Loop Counter
If Loop Counter>WordLength, End, Else Repeat loop
End
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

yeah i needed caps to

Post by idiot » Fri Apr 20, 2007 11:29 pm

that is what im trying to do
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

???

Post by idiot » Tue May 01, 2007 8:48 am

i don't get how to use the random at all little more help please?like a small example of how to use random?
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue May 01, 2007 10:16 am

To generate a random number between 1 and 10:

Random>10,rand
Let>rand=rand+1
MessageModal>Random number is: %rand%

the first parm is the range, and the second is the variable to store the result in. The result is a value between 0 and range-1.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Tue May 01, 2007 10:18 am

Greetings idiot, (sorry, couldn't resist)

Bob gave you some great advice there... psuedocode for the steps to write the macro. Look at the Help File for an example of how to use the Random> command.

Here is a simple version of what you are trying to do. See if you can modify it to include *all* the characters that you want to potentially be part of your word... including the space char if that's what you're after.

Code: Select all

Let>SourceString=ABCDEF
Let>RandomWord=
Let>k=0

Repeat>k
  Let>k=k+1
  Random>6,RandomResult
  MidStr>SourceString,RandomResult,1,Letter
  ConCat>RandomWord,Letter
Until>k=20

MDL>Your random 20 character word is:%CRLF%%CRLF%%RandomWord%
...and let us know how it turns out.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

code

Post by idiot » Tue May 01, 2007 5:56 pm

Let>SourceString=space 1234567890qwertyuiopasdfghjklzxcvbnm
Let>RandomWord=
Let>k=0

Repeat>k
Let>k=k+1
Random>34,RandomResult
MidStr>SourceString,RandomResult,1,Letter
ConCat>RandomWord,Letter
Until>k=20

send>%RandomWord%

ok i got it to type a random 20 letter word but how do i get it to do a range of 1-20?i know if i change the until>k=20 i can change the length but not sure about how to make it a range.
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue May 01, 2007 7:57 pm

You are making good progress ......

Think about these changes:

Change the 34 to 20
Replace the k with random
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed May 02, 2007 1:21 am

Bob,

34 is OK because that number is related to the number of characters in the SourceString, not the number of characters in the output RandomWord.

Idiot,

You need to generate another random number for the length of the output string. Something like this untested code:

Let>SourceString=space 1234567890qwertyuiopasdfghjklzxcvbnm
Let>RandomWord=
//get random word length
Random>19,wlen
Let>wlen=wlen+1


Let>k=0

Repeat>k
Let>k=k+1
Random>34,RandomResult
MidStr>SourceString,RandomResult,1,Letter
ConCat>RandomWord,Letter
//terminate after it has looped wlen times
Until>k=wlen

send>%RandomWord%


P.S. Why do you have that "space " at the beginning of SourceString?

Let>SourceString=space 1234567890qwertyuiopasdfghjklzxcvbnm

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

question

Post by idiot » Wed May 02, 2007 4:15 am

ok the above code does work but how do i set it to be a random range like 5-20 and not just totally random?also how would i use the writeln command to send the send>%RandomWord% to a file like say i have a file called text.txt on desktop how can i send the same result that im having it type to this file aswell?its so i can use the space bar as a character in the random word putting space either at front or back of sourcestring was easier
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Re: question

Post by jpuziano » Wed May 02, 2007 6:32 am

idiot wrote:ok the above code does work but how do i set it to be a random range like 5-20 and not just totally random?
Try this:

Code: Select all

//get random word length
//with Range=16, wlen will be a number from 0 to 15
Random>16,wlen
//now add 5 and you get a range of 5 to 20
Let>wlen=wlen+5
idiot wrote:also how would i use the writeln command to send the send>%RandomWord% to a file like say i have a file called text.txt on desktop how can i send the same result that im having it type to this file as well?
Have you looked up the Writeln> command in the Help file? Have you tried to use it? Post some code for what you've tried...
idiot wrote:its so i can use the space bar as a character in the random word putting space either at front or back of sourcestring was easier
Instead of this:

Code: Select all

Let>SourceString=space 1234567890qwertyuiopasdfghjklzxcvbnm
I'm thinking you probably want this:

Code: Select all

Let>SourceString= 1234567890qwertyuiopasdfghjklzxcvbnm
And since your SourceString contains 37 different characters (including the SPACE char) you need to generate a number from 1 - 37 for use in the MidStr> command so instead of this:

Code: Select all

Random>34,RandomResult 
MidStr>SourceString,RandomResult,1,Letter
Use this:

Code: Select all

Random>37,RandomResult
Let>RandomResult=RandomResult+1
MidStr>SourceString,RandomResult,1,Letter
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Wed May 02, 2007 6:47 am

Hi Marcus,

The example code you have for the Random> command in the Help file:

Code: Select all

Random>6,DiceResult
Message>You threw a %DiceResult% 
is misleading... No matter how may times you run this, its never going to roll a 6 and quite often rolls a 0. Dice like that can get you in trouble. :(

To roll 1-6, you might want to replace the example with this:

Code: Select all

//Set DiceResult to a random number from 0-5
Random>6,DiceResult
//Add 1, DiceResult now a number from 1-6
Let>DiceResult=DiceResult+1
Message>You threw a %DiceResult% 
Thanks Me_again, until I saw your post, I thought Random>6,Result would generate 1-6.

Now I know it generates 0-5 and you just add 1 to bump the result up to 1-6 if desired.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

code

Post by idiot » Wed May 02, 2007 12:53 pm

im pretty sure the problem im having is i dont know what command i use to grab the random result but heres what i tried and it dosent work at all

Let>SourceString=space 1234567890qwertyuiopasdfghjklzxcvbnm
Let>RandomWord=
Let>k=0
//get random word length
Random>19,wlen
Let>wlen=wlen+5


Repeat>k
Let>k=k+1
Random>37,RandomResult
MidStr>SourceString,RandomResult,1,Letter
ConCat>RandomWord,Letter
Until>k=wlen

send>%RandomWord%
putclipboard>%RandomWord%
GetClipBoard>%RandomWord%
writeln>c:\documents,text.txt,%RandomWord%
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts