Jump to content

Random shuffle Loop help - (Moved)


Recommended Posts

Hi, pretty new to autoit programming and learning.. Here i got a help request for a study project involving the study of randomness on multiple occasions. I need multiple samples, so i thought autoit was the easiest route.

What i need is to have the code be able to shuffle click all(related to analysis of distribution of randomness), but without repeats till one loop ends and again for the next loop.. i managed to compose a randomise click within an area, but stuck on how to shuffle the clicks.

 

func exitthescript()
   Exit
EndFunc

HotKeySet( "{ESC}", "exitthescript" )

while 1
   sleep(10)
   $posx = Random(930, 1050)
   $posy = Random(60, 120)
   $posx2 = Random(930, 1050)
   $posy2 = Random(120, 180)
   $posx3 = Random(930, 1050)
   $posy3 = Random(180, 240)
   $posx4 = Random(930, 1050)
   $posy4 = Random(240, 300)
   $posx5 = Random(930, 1050)
   $posy5 = Random(300, 360)
   $posx6 = Random(930, 1050)
   $posy6 = Random(360, 420)
   $posx7 = Random(930, 1050)
   $posy7 = Random(420, 480)
   $posx8 = Random(930, 1050)
   $posy8 = Random(480, 540)
   MouseClick("left", $posx, $posy, 1, 0)
   MouseClick("left", $posx2, $posy2, 1, 0)
   MouseClick("left", $posx3, $posy3, 1, 0)
   MouseClick("left", $posx4, $posy4, 1, 0)
   MouseClick("left", $posx5, $posy5, 1, 0)
   MouseClick("left", $posx6, $posy6, 1, 0)
   MouseClick("left", $posx7, $posy7, 1, 0)
   MouseClick("left", $posx8, $posy8, 1, 0)

   WEnd

Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Does this work for you?

HotKeySet( "{ESC}", "exitthescript" )

Local $posx1 = 0, $posy1 = 0

For $c = 1 To 8
$posx = Random(930, 1050, 1)
$posy = Random(60, 540, 1)
If $posx1 <> $posx And $posy1 <> $posy Then
;MouseClick("left", $posx, $posy, 1, 0)
ConsoleWrite($posx &' - '& $posy &' - '& @MSEC&@CRLF)
$posx1 = $posx
$posy1 = $posy
EndIf
Sleep(100)
Next

func exitthescript()
   Exit
EndFunc

 

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Here is another example that may help.

#include <Array.au3>

HotKeySet("{ESC}", "Terminate")

Local $iInc = 60, $iRandYMin = $iInc, $iRandYMax = $iRandYMin + $iInc
Local $aY[9] = [8], $aX[UBound($aY)] = [UBound($aY) - 1] ; Instead of 2 - 1D arrays, could use 1 - 2D array to hold X and Y coordinates.

While 1
    Sleep(10)
    $iRandYMin = $iInc
    $iRandYMax = $iRandYMin + $iInc
    ConsoleWrite('"Y" Range:-' & @CRLF)
    For $i = 1 To 8
        $aX[$i] = Random(930, 1050, 1) ;              Random 8 "X" coordinate values.
        $aY[$i] = Random($iRandYMin, $iRandYMax, 1) ; Random 8 "Y" coordinate values.
        ConsoleWrite("Random(" & $iRandYMin & ", " & $iRandYMax & ", 1)" & @CRLF)
        $iRandYMin = $iRandYMax
        $iRandYMax = $iRandYMin + $iInc
    Next

    _ArrayShuffle($aY, 1) ; Randomize the random "Y" values of each area where the random mouse clicks will be made.
    ;_ArrayDisplay($aY)
    ConsoleWrite("MouseClick (X, Y):-" & @CRLF)
    For $i = 1 To 8
        MouseClick("left", $aX[$i], $aY[$i], 1, 0)
        ConsoleWrite($aX[$i] & ", " & $aY[$i] & @CRLF)
    Next
WEnd


Func Terminate()
    Exit
EndFunc   ;==>Terminate

#cs ; Output example:-
"Y" Range:-
Random(60, 120, 1)
Random(120, 180, 1)
Random(180, 240, 1)
Random(240, 300, 1)
Random(300, 360, 1)
Random(360, 420, 1)
Random(420, 480, 1)
Random(480, 540, 1)
MouseClick (X, Y):-
1020, 317
1013, 254
1010, 442
962, 71
963, 505
1005, 416
939, 140
1025, 209
#ce

 

Link to comment
Share on other sites

3 hours ago, careca said:

HotKeySet( "{ESC}", "exitthescript" ) Local $posx1 = 0, $posy1 = 0 For $c = 1 To 8 $posx = Random(930, 1050, 1) $posy = Random(60, 540, 1) If $posx1 <> $posx And $posy1 <> $posy Then ;MouseClick("left", $posx, $posy, 1, 0) ConsoleWrite($posx &' - '& $posy &' - '& @MSEC&@CRLF) $posx1 = $posx $posy1 = $posy EndIf Sleep(100) Next func exitthescript()    Exit EndFunc

Made a little syntax before the mouseclick cmd and added a while wend, this shuffled clicks but repeated them, i could use this too. thankyou.

 

1 hour ago, Malkey said:

#include <Array.au3> HotKeySet("{ESC}", "Terminate") Local $iInc = 60, $iRandYMin = $iInc, $iRandYMax = $iRandYMin + $iInc Local $aY[9] = [8], $aX[UBound($aY)] = [UBound($aY) - 1] ; Instead of 2 - 1D arrays, could use 1 - 2D array to hold X and Y coordinates. While 1     Sleep(10)     $iRandYMin = $iInc     $iRandYMax = $iRandYMin + $iInc     ConsoleWrite('"Y" Range:-' & @CRLF)     For $i = 1 To 8         $aX[$i] = Random(930, 1050, 1) ;              Random 8 "X" coordinate values.         $aY[$i] = Random($iRandYMin, $iRandYMax, 1) ; Random 8 "Y" coordinate values.         ConsoleWrite("Random(" & $iRandYMin & ", " & $iRandYMax & ", 1)" & @CRLF)         $iRandYMin = $iRandYMax         $iRandYMax = $iRandYMin + $iInc     Next     _ArrayShuffle($aY, 1) ; Randomize the random "Y" values of each area where the random mouse clicks will be made.     ;_ArrayDisplay($aY)     ConsoleWrite("MouseClick (X, Y):-" & @CRLF)     For $i = 1 To 8         MouseClick("left", $aX[$i], $aY[$i], 1, 0)         ConsoleWrite($aX[$i] & ", " & $aY[$i] & @CRLF)     Next WEnd Func Terminate()     Exit EndFunc

Worked like a charm exactly what i was expecting..included a sleep timer and checked it too.. Thankyou.

Wish i could find a good autoit tutorial, so far ive been catching up on bits and parcels here and there.

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