Sign in to follow this  
Followers 0
Xtian

how to do random clicks on list

9 posts in this topic

can anyone help me fill up or give ideas on what to do with the missing code so i can do random clicks on the list.

thanks in advance.

here's the code:

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

Example()

Func Example()

Local $mylist, $msg,$clickrandom

GUICreate("My GUI",250,250)

$mylist = GUICtrlCreateList("", 20, 20, 200, 200)

$clickrandom = GUICtrlCreateButton("random click", 20, 220, 200, 20); open url on list to ie embed window

GUISetState()

for $i=1 to 10

GUICtrlSetData($mylist,"Click me 1st |")

Next

$msg = 0

While $msg <> $GUI_EVENT_CLOSE

$msg = GUIGetMsg()

Select

Case $msg = $clickrandom

;some missing code here; help please

msgbox(0,"message","you click entry #");

EndSelect

WEnd

EndFunc


Sorry for being noob but... thanks to you im learned something new.

Share this post


Link to post
Share on other sites



for educational purposes... well i was thinking of clicking random images or names .

for example i want to decide who will be the winner or something like that.


Sorry for being noob but... thanks to you im learned something new.

Share this post


Link to post
Share on other sites

sorry but i dont know how to explain this but, think of it as a dice game...

instead of rolling a dice and showing random numbers, it will display name or things you want to do when your name got selected..

each name on that list for example will trigger new event.. like:

1. play a movie

2. play mp3

3. etc...

hope it makes sense.


Sorry for being noob but... thanks to you im learned something new.

Share this post


Link to post
Share on other sites

Instead of why, I looked at how.

Maybe this.

Example()

Func Example()
    Local $mylist, $msg, $clickrandom, $hGui
    Local $sList
    Local $aArray[11] = ["Click me 0"]

    $hGui = GUICreate("My GUI", 250, 250)

    $clickrandom = GUICtrlCreateButton("random click", 20, 220, 200, 20); open url on list to ie embed window
    $mylist = GUICtrlCreateList("", 20, 20, 200, 200)

    $sList = "Click me 0"
    For $i = 1 To 10
        $sList &= "|Click me " & $i
        $aArray[$i] = "Click me " & $i
    Next
    GUICtrlSetData($mylist, $sList, $aArray[3])
    GUISetState()

    While $msg <> -3 ; $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        Select
            Case $msg = $clickrandom
                GUICtrlSetData($mylist, "")
                GUICtrlSetData($mylist, $sList, $aArray[Random(0, UBound($aArray) - 1, 1)])
                MsgBox(0, "message", "you click entry #" & GUICtrlRead($mylist), 2, $hGui);
        EndSelect
    WEnd
EndFunc   ;==>Example

Share this post


Link to post
Share on other sites

thanks malkey, unfortunately i tried to use your code here but i dont know what to do..

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Example()
Func Example()

$hgui=GUICreate("My Playlist",250,300)

$mylist = GUICtrlCreateList("Playlist0", 20, 20, 200, 200)
$autoplay = GUICtrlCreateButton("Auto Play", 20, 240, 200, 20);
$loadfile=GUICtrlCreateButton("Load Text File",20,220,200,20)
$linecnt=GUICtrlCreateLabel("Number of Lines:",20,260,200,20)
$status=GUICtrlCreateLabel("Status",20,280,200,20)
[attachment=37924:test.txt]
GUISetState()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
     $msg = GUIGetMsg()

Select
case $msg = $autoplay


;want to do random clicks here instead of pressing down arrow or play from the start again when it reach the last file///////
;and how do i make it start from playlist 0 because it keeps on playing on #16 first lol..

ControlClick("My Playlist","",$mylist,"left",1)
send("{down}")
$nowplaying = GUICtrlRead($mylist)
GUICtrlSetData($status,"Status: Now Playing " & $nowplaying)
;Sleep(500)
;Send("{down}")

     case $msg = $loadfile

$file=FileOpen("test.txt",0)
$cnt=0
while 1
$readline= FileReadLine($file)
$cnt= $cnt+1
If @error = -1 Then ExitLoop
GUICtrlSetData($mylist, $readline & "|")
wend
GUICtrlSetData($linecnt,"Number of Lines:" & $cnt)
FileClose($file)
GUICtrlSetState($loadfile,$gui_disable)

     EndSelect
WEnd
EndFunc

test.txt


Sorry for being noob but... thanks to you im learned something new.

Share this post


Link to post
Share on other sites

Try this with your test.txt file in the same directory as this script.

#include <File.au3>
#include <Array.au3>


Example()

Func Example()
    Local $mylist, $msg, $clickrandom, $hGui
    Local $sList, $aArray
    Local $aArray[11] = ["Click me 0"]

    $hGui = GUICreate("My GUI", 250, 250)

    $clickrandom = GUICtrlCreateButton("random click", 20, 220, 200, 20); open url on list to ie embed window
    $mylist = GUICtrlCreateList("", 20, 20, 200, 200)

    _FileReadToArray("test.txt", $aArray)
    _ArrayDelete($aArray, 0)
    $sList = _ArrayToString($aArray, "|")

    GUICtrlSetData($mylist, $sList, $aArray[3])

    GUISetState()

    While $msg <> -3 ; $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        Select
            Case $msg = $clickrandom
                GUICtrlSetData($mylist, "")
                GUICtrlSetData($mylist, $sList, $aArray[Random(0, UBound($aArray) - 1, 1)])
                MsgBox(0, "message", "you click entry #" & GUICtrlRead($mylist), 2, $hGui);
        EndSelect
    WEnd
EndFunc   ;==>Example

Share this post


Link to post
Share on other sites

thanks again, working on it now :D


Sorry for being noob but... thanks to you im learned something new.

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