Sign in to follow this  
Followers 0
michiev

Randomized scrolling through a list.

10 posts in this topic

I know this is probably confusing but I'll try to explain it, I'm fairly new at using AutoIT and I'm insanely unsure of what I'm doing or what I can do.. So, I would like to be able to have a list of words and be able to run a script that will cycle through those words automatically and stop at a randomized word (The list of words can be numbered as well) Think of it as like pulling a piece of paper out of a hat at random, Thats what I'm trying to do.. Although I have no idea where I would start..

Any advice?

Share this post


Link to post
Share on other sites



#include <File.au3>

Local $Array
_FileReadToArray("list.txt",$Array)

MsgBox(0,"Random word",$Array[Random(1,$Array[0],1)])

Make a file called list.txt in script folder.

file it with

word1
word2
word3
word4
etc...

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Thanks for the help, But can you explain more about this "Script" folder? I don't know where thats supposed to be or what.

Share this post


Link to post
Share on other sites

JohnOne means that you should create the text file in the same folder where your script resides.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Thanks for the help guys! I've got another question.. I'm trying to get the script to loop through the randomized list.. It pops up a window with "Word1" and I click okay, The windows goes away... I would like to find a way to loop it so it would go through all of the words on the list by popping up each in it's own little popup window until it got to the end of the list.

Share this post


Link to post
Share on other sites

Hi, michiev. Can you please post the code you have thus far? It will be easier to modify what you have to work the way you want it, rather than trying to write something from scratch to meet your needs. :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Oh dur, I didn't think of posting it until now, I'm sorry :)

Here you go:

#include <file.au3>

#include <Array.au3>

Local $FileArray

Local $RandomNumber

Local $UsedNumbersArray

Local $Counter = 1

_FileReadToArray("list.txt",$FileArray)

while ($Counter < $FileArray[0])

$RandomNumber = Random(1, $FileArray[0])

if $RandomNumber not In $UsedNumbersArray Then

$Counter = $Counter + 1

MsgBox(0, "Random Word",$FileArray[$RandomNumber])

EndIf

WEnd

thats the code I have so far. I keep getting errors in the compiler

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

It's erroring because that is not autoit syntax

"not in" means nothing to autoit.

Read your file into an arrayshuffle the array,

you can find a shuffel function by SmOke_N

Loop through the resulting array, and output its contents as you do.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Are there any good guides on auttoarrays/shuffling?

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