Jump to content

Randomized scrolling through a list.


michiev
 Share

Recommended Posts

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?

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

Link to comment
Share on other sites

  • Moderators

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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

Link to comment
Share on other sites

  • Moderators

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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

Link to comment
Share on other sites

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.

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