Jump to content
Sign in to follow this  
Eternal

About Func and If

Recommended Posts

Eternal

Hello! Well - it's, possible, noob problem, but still very important to me.

First of all - my aim is to create an auto clicker for 3 or more buttons. Well, I'll try to explain what i already learned in couple hours and what i want to figure out.

Searched for script - and found this:

HotKeySet("{F9}","onoff")

Dim $click = False

Func onoff()
   If $click = False Then
      $click = True
   Else
      $click = False
   EndIf
EndFunc

While True
   If $click = True Then
      MouseClick("left")
   EndIf
   Sleep(50)
WEnd

Well, almost everything is ok for me, except - why there is: Dim $click = false ? - Declare variable - but why false? 0_o (Possible i am stupid lol) :mellow:

Really nice script for clicker, but it works well only for 1 function, if i am going to add a function, that clicks right mouse button - it just doesn't works. Example:

HotKeySet("{F9}","onoff")
HotKeySet("{F8}","right")

Dim $click = False
Dim $right = False

Func onoff()
   If $click = False Then
      $click = True
   Else
      $click = False
   EndIf
EndFunc

While True
   If $click = True Then
      MouseClick("left")
   EndIf
   Sleep(50)
WEnd

Func right()
    If $right = False Then
        $right = True
    Else
        $right = False
    EndIf
EndFunc

While True
    If $right = True Then
        MouseClick("right")
    EndIf
    Sleep(1000)
WEnd

As I am a beginner - i am not sure, where is the problem... still trying other ways of this clicker.

Here is the other script i found:

HotKeySet("{NUMPADMULT}","mouseleft")
HotKeySet("{NUMPADSUB}", "mouseright")
HotKeySet("{TAB}", "heal")

Dim $mouseleft, $mouseright, $heal

Func mouseleft()
    While(1)
        If $mouseleft = true Then
            MouseClick("left")
        Elseif $mouseleft = False Then
            $mouseleft = True
        Endif
    WEnd
EndFunc

Func mouseright()
    While(1)
        If $mouseright = True Then
            Mouseclick("right")
        ElseIf $mouseright = False Then
            $mouseright = True
        EndIf
    WEnd
EndFunc

While(1)
    sleep(50)
Wend

Func heal()
    While(2)
        If $heal = True Then
            Send("q")
        ElseIf $heal = False Then
            $heal = True
        EndIf
    WEnd
EndFunc

While(2)
    Sleep(1000)
WEnd

This script just starts clicking, but didn't stops it, well i guess that it could be done by adding 1 more func like: If $mouseleft = True Then

$mouseleft = False

EndIf

If $mouseright = True Then

$mouseright = False

EndIf

If $heal = True Then

$heal = False

EndIf

But if adding something like this - it stops clicking and Exits programm...

So I would like to see the solution of this problem without use of huge scripting... cus i am beginner anyway - just started - so any clues would be wonderful (don't forget to add comments on any functions you are going to write - it would be great to learn something new)

Share this post


Link to post
Share on other sites
dani

Func onoff()
   If $click = False Then
      $click = True
   Else
      $click = False
   EndIf
EndFunc

While True
   If $click = True Then
   ..

Can be changed to:

Func onoff()
    $click = Not $click
EndFunc

While True
   If $click Then
   ..

They are functionally the same though.

Your script for rightclicking doesn't work because your script goes into the first While True ... WEnd loop and never leaves it -- True is always true :( That first loop only includes the MouseClick("left"). You can combine the two loops into one if you want them both to be executed.

The last script you mentions is odd, just use the first which looks fine to me, and somehow integrate MouseClick("left") and MouseClick("right") into one loop. I'm sure you can figure that out :mellow:

Edited by dani

Share this post


Link to post
Share on other sites
Yoriz

A tip for your loops

While True
   Other code here
Wend

While true will always be true so this loop will continue forever, it cant get to your right click loop because its forever doing your left click loop.

to exit that loop you can set a statment that tells it to use 'ExitLoop' or change the 'while true' to something that wont always be true like 'while $a = true'

so that $a can become not true to exit the loop.


GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites
Eternal

Guys - You are fantastic :mellow:

It really helped me, so I changed script a bit and it's working now as I wanted - now it is something in this way:

Func onoff()
    $click = NOT $click
EndFunc


Func right()
    $right = NOT $right
EndFunc


While True
   If $click Then
   MouseClick("left")
   ElseIf $right Then
    MouseClick("right")
   Endif
   Wend

Made the Func using NOT and mixed both While's into one... so the script is running as i wanted... clicking both mouse buttons and doesn't exits after stopping. Huh, seems that i have much to learn in next few months.

Anyway - big thanks for this :(

Share this post


Link to post
Share on other sites
dani

Glad we could be of help :mellow:

Share this post


Link to post
Share on other sites
Zeropker

Any way to make this faster?

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  

×