Jump to content

Recommended Posts

Posted

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

  • Moderators
Posted

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:

  Reveal hidden contents

 

Posted

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

 

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted

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

 

Posted
  On 5/31/2020 at 9:46 AM, 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

Expand  

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.

 

  On 5/31/2020 at 11:51 AM, 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

Expand  

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...