Sign in to follow this  
Followers 0
bigassmuffin

Loop mouse click every x seconds?

19 posts in this topic

How can I make a continues loop troughout whole script where it keeps pressing the left mouse button every 5 seconds wherever the cursor may be

I know there is :

MouseClick('left', $coord[0], $coord[1] - 0, 1, 0)

but how can I get this to keep looping?

Share this post


Link to post
Share on other sites



How can I make a continues loop troughout whole script where it keeps pressing the left mouse button every 5 seconds wherever the cursor may be

I know there is :

MouseClick('left', $coord[0], $coord[1] - 0, 1, 0)

but how can I get this to keep looping?

While(1)

MouseClick('left', $coord[0], $coord[1] - 0, 1, 0)

Sleep(5000)

WEnd

Nomad :D


Share this post


Link to post
Share on other sites

While(1)

MouseClick('left', $coord[0], $coord[1] - 0, 1, 0)

Sleep(5000)

WEnd

Nomad :D

I already have a While1, should I change to While2? lol

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

or, since I misunderstood the question, start a timer and make it go to a function every 5 seconds like:

$begin = TimerInit()

;

;script stuff

;

$dif = TimerDiff($begin)

If $dif > 5000 Then MouseClick()

;

;more script stuff

;

 

Func MouseClick()

MouseClick('left', $coord[0], $coord[1] - 0, 1, 0)

EndFunc

Experiment around. The way this is implemented depends on your script. You may also need additional timers or a way to bypass this existing timer if the script is going to loop around in less than 5 seconds, or it will restart the timer and never go to the function.

Edit: you also can't use MouseClick as a function name, it was just an example.:D

Edited by Nomad

Share this post


Link to post
Share on other sites

I already have a While1, should I change to While2? lol

It doesn't matter. The 1 is just a statement that is always true and that's why it makes the While continue to loop. You can use any number you want, but it doesn't change anything if you use the same number over and over.


Share this post


Link to post
Share on other sites

This is a classic case of, "Can I" , "I have", "No I won't Show... But answer my question anyway".


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

This is a classic case of, "Can I" , "I have", "No I won't Show... But answer my question anyway".

It's also a regular case in this forum.:D


Share this post


Link to post
Share on other sites

Is it possible to define a function in a script that is defined by autoit?

in nomads script he defines MouseClick() but then he calls Mouseclick(left,...) in the function. I think it wont work or?


--------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

wat im trying to go for is combining two scripts to keep playing and looping together..whcih are these two scripts:

Opt("WinTitleMatchMode",2)
WinWaitActive("[Conquer2.0]")
$color = 0xB50400
$color2 = 0xFFD76B
$game = 0
HotKeySet("+q", "Play")
HotKeySet("{ESC}", "quit")
While 1
    If $game = 1 Then
        $coord = PixelSearch( 0, 0, 1023, 651, $color, 10, 20)
        If IsArray($coord) = 1 Then
            MouseClick('left', $coord[0], $coord[1] - -30, 1, 0)
            Sleep(3000)

        EndIf
    EndIf   
WEnd   



Func Play()
    If $game < 1 Then
        $game = $game + 1
    Else
        $game = 0
    EndIf
EndFunc
 
Func quit()
    Exit
EndFunc

AND

While 1
    If $game = 1 Then
        $coord = PixelSearch( 0, 0, 1023, 651, $color2, 30, 5)
        If IsArray($coord) = 1 Then
            MouseClick('left', $coord[0], $coord[1] - 0, 1, 0)
            Sleep(3000)
        EndIf
    EndIf   
WEnd

Can I jsut do:

(nm, that doesnt work?)

Opt("WinTitleMatchMode",2)
WinWaitActive("[Conquer2.0]")
$color = 0xB50400
$color2 = 0xFFD76B
$game = 0
HotKeySet("+q", "Play")
HotKeySet("{ESC}", "quit")
While 1
    If $game = 1 Then
        $coord = PixelSearch( 0, 0, 1023, 651, $color, 10, 20)
        If IsArray($coord) = 1 Then
            MouseClick('left', $coord[0], $coord[1] - -30, 1, 0)
            Sleep(3000)

        EndIf
    EndIf   
WEnd   


While 1
    If $game = 1 Then
        $coord = PixelSearch( 0, 0, 1023, 651, $color2, 30, 5)
        If IsArray($coord) = 1 Then
            MouseClick('left', $coord[0], $coord[1] - 0, 1, 0)
            Sleep(3000)
        EndIf
    EndIf   
WEnd   


Func Play()
    If $game < 1 Then
        $game = $game + 1
    Else
        $game = 0
    EndIf
EndFunc
 
Func quit()
    Exit
EndFunc

???????

Edited by bigassmuffin

Share this post


Link to post
Share on other sites

No autoit doesnt support multithreading, thats like saying im going to go run around the track while i sit down and take a crap on the toilet

Share this post


Link to post
Share on other sites

No autoit doesnt support multithreading, thats like saying im going to go run around the track while i sit down and take a crap on the toilet

lol, thanks for the help, but is there any way then for it to jsut first read for the first color, then read if theres second color, and keep doing that as a loop?

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

lol, thanks for the help, but is there any way then for it to jsut first read for the first color, then read if theres second color, and keep doing that as a loop?

I believe you should just be able to include both while loops together into 1

Heres a code

Opt("WinTitleMatchMode",2)
WinWaitActive("[Conquer2.0]")
$color = 0xB50400
$color2 = 0xFFD76B
$game = 0
HotKeySet("+q", "Play")
HotKeySet("{ESC}", "quit")


While 1
          If $game = 1 then
    $coord = PixelSearch( 0, 0, 1023, 651, $color, 10, 20)
         If IsArray($coord) = 1 Then
        MouseClick('left', $coord[0], $coord[1] - -30, 1, 0)
        Sleep(3000)
         EndIf 
    $coord1 = PixelSearch( 0, 0, 1023, 651, $color2, 30, 5)
         If IsArray($coord1) = 1 Then
        MouseClick('left', $coord1[0], $coord1[1] - 0, 1, 0)
        Sleep(3000)
         EndIf
         Endif
WEnd   

Func Play()
    If $game < 1 Then
        $game = $game + 1
    Else
        $game = 0
    EndIf
EndFunc

Func quit()
    Exit
EndFunc

That should work and search for 2 colors

Edit:Code Typo

Edited by Paulie

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I believe you should just be able to include both while loops together into 1

Heres a code

Opt("WinTitleMatchMode",2)
WinWaitActive("[Conquer2.0]")
$color = 0xB50400
$color2 = 0xFFD76B
$game = 0
HotKeySet("+q", "Play")
HotKeySet("{ESC}", "quit")

While $game = 1
    $coord = PixelSearch( 0, 0, 1023, 651, $color, 10, 20)
         If IsArray($coord) = 1 Then
        MouseClick('left', $coord[0], $coord[1] - -30, 1, 0)
        Sleep(3000)
         EndIf 
    $coord1 = PixelSearch( 0, 0, 1023, 651, $color2, 30, 5)
         If IsArray($coord1) = 1 Then
        MouseClick('left', $coord1[0], $coord1[1] - 0, 1, 0)
        Sleep(3000)
         EndIf
WEnd   

Func Play()
    If $game < 1 Then
        $game = $game + 1
    Else
        $game = 0
    EndIf
EndFunc

Func quit()
    Exit
EndFunc

That should work and search for 2 colors

Edit:Code Typo

Thank you very much for all your time in this script, but unfortunatly it does not work, as soon as I alt tab or click into the game, the script automaticcly cancels

(I feel guilty reading your signature paulie in this thread <:D )

Edited by bigassmuffin

Share this post


Link to post
Share on other sites

:">

Thank you very much for all your time in this script, but unfortunatly it does not work, as soon as I alt tab or click into the game, the script automaticcly cancels

(I feel guilty reading your signature paulie in this thread <:D )

I edited my post, sorry had a mistake, now it should work :">

as for the sig

You at least tried to do it on your own, not just come here and be like

Heyy au3forums!!!!11!!!!11! WRIT3 ME AN U83r 1337 AIMBOT, PLZZZZ!!!!!!!!!!!!11!!!1!

That wht the sig is ment for

Share this post


Link to post
Share on other sites

:">

I edited my post, sorry had a mistake, now it should work :">

as for the sig

You at least tried to do it on your own, not just come here and be like

That wht the sig is ment for

WORKS --->PERFECT<---

THANK YOU!

Share this post


Link to post
Share on other sites

WORKS --->PERFECT<---

THANK YOU!

No problem, glad i could help

Share this post


Link to post
Share on other sites

Is it possible to define a function in a script that is defined by autoit?

in nomads script he defines MouseClick() but then he calls Mouseclick(left,...) in the function. I think it wont work or?

No, you can't use a AutoIt predefined function as a function name. Which is why I edited my post at the bottom saying:

Edit: you also can't use MouseClick as a function name, it was just an example.:D

Nomad :D


Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

I am a total noob to all of this..

How would I just make it so that I can get my mouse to double click, lets say every 60 seconds

MouseMove(1230, 779, 0)

func _mouseclick("left", 0, 500, 2)

while 1

sleep(10)

wend

EndFunc

I understand this but I have no idea how to put ths in a loop or even what the code would be. Could you help me Please

Edited by jazs

Share this post


Link to post
Share on other sites

While 1
    Sleep(60000)
    MouseClick('Left', 100, 100, 2, 1)
WEnd


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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