Jump to content

Recommended Posts

Posted

Hello so ive been wondering how do I make my script run multiple times?

like a mouse will click on a pixel that the pixel search has found and I want my script to do it again.

Example Code:

$var1 = PixelSearch ( 0,0, 1279, 1023, 0xFF0000 )
If Not @error Then
MouseClick("Left", $var[0], $var[1], 1)
EndIf

I know I need to use Do or While Loop but I don't know how to use them well.

Posted

I guess you are learning autoit.

Well it is kinda simpel, look at the helpfile or autoit3\Examples\Helpfile\For.au3

-jaenster

Posted (edited)

You should put the Sleep inside the While loop.

$t = 0
while $t < 10 
msgbox(0,"","Hi")
$t = $t + 1
sleep(1000)
wend

Edit: I didn't see your "Please reply quick" and I agree Tvern, that isn't the right way to ask for help.

Edited by sahsanu
Posted

Your sleep will only be executed when the loop is finished.

You'd want your code to look liek this.

Local $t = 0
While $t < 10
    MsgBox(0,"","Hi")
    Sleep(1000) ;put the sleep inside the loop
    $t += 1 ;this is another way to increate $t by 1
Wend

A For...To...Next loop would be better for this code:

For $t = 0 To 9 ;this declares $t and automatically increments it by 1, untill $t is 9 at which point the loop will run one last time before it exits.
    MsgBox(0,"","Hi")
    Sleep(1000)
Next

Please reply quick

That almost stopped me from replying. I doubt anyone will feel more inclined to help you if you tell em to be quick about it.

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
×
×
  • Create New...