Jump to content
Sign in to follow this  
Clever1mba

randomly change

Recommended Posts

hello

littile problem in this code i need to change randomly text in file.txt

file.txt contain name like this

asim

adil

akber

ali

john

james

now every 3 sec i want to change name in GUICtrlCreateInput randomly

i hope u get my point

#include <GUIConstants.au3>

GUICreate("gui")

$fHandle1 = FileOpen(@SystemDir & "\myfile.txt", 0)

$char = FileRead($fHandle1, 99999999)

FileClose($fHandle1)

$service = StringSplit($char, @CRLF)

For $i = 1 to $service[0]$input2 = GUICtrlCreateInput($service[$i],70,40,250,20)

GUISetState ()

Next

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend

Edited by asimzameer

Share this post


Link to post
Share on other sites

#include<file.au3>
_FileReadToArray(@SystemDir & "\myfile.txt", $array)
$line = Rand(1, $array[0], 1)
GuiCtrlSetData($input2, $array[$line])

should work.

Edited by MSLx Fanboy

Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

You want to go in an actual order?

#include<file.au3>
_FileReadToArray(@SystemDir & "\myfile.txt", $array)
For $line = 1 to $array[0]
GuiCtrlSetData($input2, $array[$line])
Sleep(1000*3)
Next

If you want to continue looping through those indefinately then...

#include<file.au3>
_FileReadToArray(@SystemDir & "\myfile.txt", $array)
For $line = 0 to $array[0]
GuiCtrlSetData($input2, $array[$line])
Sleep(1000*3)
If $line = $array[0] Then $line = 0
Next

I didn't test the code...but it should work


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...