Jump to content

A very simple clicker


Xaio
 Share

Recommended Posts

Hello!

I'm trying to make a clicker script that automaticly clicks, it should also be able to be toggeled and closed entirely.

The code i've come up to so far is:

HotKeySet("{BACKSPACE}", "fx")
$ison = 1
Func fx()
If $ison Then
$ison = 0
Else
$ison = 1
EndIf
EndFunc

While 1
If $ison Then
MouseClick("left")
Sleep(100)
MouseClick("left")
sleep(100)
EndIf

WEnd

The problem with this, and im i've tried to find some other ways but since im new to coding over all except for html/css this is a maze.

Backspace is just a test key, luckly i noticed that as long as the script runs i cant use backspace at all and thats annoying.. (yes its a freaking dumb key, my own fault.. hah)

I know that i can compile code to EXE, so i thought i just have to run the program every time(macro it for startup!!! ehm just kidding), but third mouse button should pause the clicks function and also resume(just as backspace does now) and F12(could be some other key) should close the "program/script" entirely.

Be easy on me, im a fast learner but to much information at once can make me confused.

Thanks in advance, and for the awesome program!

-Xaio

Oh, and when im learning more im gonna add other features for my own, and im looking forward to it!

Link to comment
Share on other sites

Look here http://www.autoitscript.com/forum/index.php?showtopic=90492

And a little advice, if thats the kind of thing your school wants you to learn as part of a curriculum, you might want to ponder your future, and ask you a usefull assignment.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Hello!

I'm trying to make a clicker script that automaticly clicks, it should also be able to be toggeled and closed entirely.

The code i've come up to so far is:

HotKeySet("{BACKSPACE}", "fx")
$ison = 1
Func fx()
If $ison Then
$ison = 0
Else
$ison = 1
EndIf
EndFunc

While 1
If $ison Then
MouseClick("left")
Sleep(100)
MouseClick("left")
sleep(100)
EndIf

WEnd

The problem with this, and im i've tried to find some other ways but since im new to coding over all except for html/css this is a maze.

Backspace is just a test key, luckly i noticed that as long as the script runs i cant use backspace at all and thats annoying.. (yes its a freaking dumb key, my own fault.. hah)

I know that i can compile code to EXE, so i thought i just have to run the program every time(macro it for startup!!! ehm just kidding), but third mouse button should pause the clicks function and also resume(just as backspace does now) and F12(could be some other key) should close the "program/script" entirely.

Be easy on me, im a fast learner but to much information at once can make me confused.

Thanks in advance, and for the awesome program!

-Xaio

Oh, and when im learning more im gonna add other features for my own, and im looking forward to it!

What's the aim? Where are you trying to click? Why don't you change the hotkey? Why not setup another hotkey to close the program?

I think this is a nicer fx function

Func fx()
    $ison = NOT $ison
EndFunc
Link to comment
Share on other sites

Thanks for the replies!

Gonna check it out, a friend of mine helped me with half the code so i have to nest it out and see how it works. Im familiar to a few things!

Ill come back if i remember to post the finished code or if i need some more help

<3

Link to comment
Share on other sites

What's the aim? Where are you trying to click? Why don't you change the hotkey? Why not setup another hotkey to close the program?

I think this is a nicer fx function

Func fx()
    $ison = NOT $ison
EndFunc

Argh didnt see any edit, and forgot to reply. First of all its a program to show up for the school but its used in a game, Diablo2.

My frenzybarb is just running around and he hits 5 hits per sec so i wanna save the mouse and my finger from being damaged over time.. lol

This could be discussed as a cheat, but its singleplayer so it dosnt bother any other than me.

But if i compile, does a exit script = exit exe? oh well gonna sit down now after eating to get it sorted out!

Link to comment
Share on other sites

Not to get into the whole use in a game debate, just a side note for knowledge sake because I'm feeling picky. Don't use the term compile. AutoIt is not a compiler language. It is interpreted 1 step at a time by an interpreter, sort of like java. It has to do this every time it is run unlike a compiled language like C++ where an executable is compiled and optimized into machine code. The executable AutoIt builds is just the source and the interpreter packaged into a .exe file with some instructions to run the source.

Link to comment
Share on other sites

Noobish question, scrips can just be runned by clicking on them?

Then theres no need to compile!

1st that is an option not a requirement, I personally like to have it edit on a double click not run. 2nd This means it will only work for people with AutoIt installed. If you wanted to write a script anyone (with windows of course) can use then you need to build an executable.

Link to comment
Share on other sites

Just a side note for knowledge sake because I'm feeling picky. But people without AutoIt installed can execute scripts through another AutoIt executable. (Info under "Command Line" in the help file) ;)

Edit: I just thought I'd start a little Pedantic battle. It's not a very practical way to run scripts. I'm done bumping this topic now.

Edited by Tvern
Link to comment
Share on other sites

You are right, I worded it incorrectly. I was trying to make the point that if you only had .au3 files and have it set to run as the default action. You wouldn't be able to give it to someone 'as is', with nothing else and say double click to run it. They would need to have an executable to run it through and the proper command line.

Link to comment
Share on other sites

Ok, so im finished and its working ALMOST as i want it to, or well everything works as it should but i want the pause key to middle mouse button, im such demanding! hah

And i cant seem to find it, if you start typing mouse you get several options, but its mouse scroll and such, and i must thank everyone in this thread! I didnt use what you linked JohnOne, thought i understod this more.

HotKeySet("{F4}", "quit")
HotKeySet("{F2}", "pause")

Func quit()
Exit
EndFunc

$ison = 1
Func pause()
$ison = NOT $ison
Endfunc

While 1
If $ison Then
MouseClick("left")
Sleep(1000)
MouseClick("left")
sleep(1000)
EndIf
WEnd
Link to comment
Share on other sites

HotKeySet("{F4}", "quit")
HotKeySet("{F2}", "pause")

Func quit()
Exit
EndFunc

$ison = 1
Func pause()
$ison = NOT $ison
Endfunc

While 1
If $ison Then
MouseClick("left")
Sleep(1000)
MouseClick("left")
sleep(1000)
EndIf
WEnd

Tips:

1) please structure your code. The Tidy tool works well but really all your missing is proper spacing for easier reading.

2) Having 2 sets of MouseClick() Sleep() inside a loop really does nothing for you. Just put one, it still loops until paused anyway.

3) You don't need to sleep for 1000 unless you need that long of a pause between clicks. If your goal is simply to stop the cpu from running wild. A Sleep(1) or Sleep(10) is all you really need.

4) It might be better to have clicker scripts start in the paused state. This way you can start it any time and have time to move the mouse where you want before the clicking starts. Rather than running the script and having it start clicking before your mouse is where it needs to be.

5) (this one is just my personal preference) Using True/False rather than 1/0 makes code easier to read and 1 less type conversion to a boolean value for the interpreter.

Edited by ShawnW
Link to comment
Share on other sites

Tips:

1) please structure your code. The Tidy tool works well but really all your missing is proper spacing for easier reading.

2) Having 2 sets of MouseClick() Sleep() inside a loop really does nothing for you. Just put one, it still loops until paused anyway.

3) You don't need to sleep for 1000 unless you need that long of a pause between clicks. If your goal is simply to stop the cpu from running wild. A Sleep(1) or Sleep(10) is all you really need.

4) It might be better to have clicker scripts start in the paused state. This way you can start it any time and have time to move the mouse where you want before the clicking starts. Rather than running the script and having it start clicking before your mouse is where it needs to be.

5) (this one is just my personal preference) Using True/False rather than 1/0 makes code easier to read and 1 less type conversion to a boolean value for the interpreter.

#1, yes but i thougt i did a good job, lol. You shouldnt see my psd files and ive been working in photoshop for over 11 years...

#2 Has to click twice, a dubbleclick would work, but i never looked at it again after the first working version.

#3 It were for the testing, i didnt want to have rapid clicking all over, should be at 100, if it goes lower than 50 the game will shut down (or so they say)

#4 Ya, But ive not experienced enough, the functions is only called, so i have to make some pause until the key for the pause key is pushed BEFORE $ison = 1 (lol sorry couldnt resist) , working on it right away!

#5 my friend wrote that part of the code, so i didnt dare to touch it nor know how it worked, but i guess its all the 1s that could be changed to True instead, and yes i agree with you.

Still dosnt solve the third mousebutton key :/ its all ok as it is but i want perfection and thanks to you i got another thing fixed!

Link to comment
Share on other sites

#1, yes but i thougt i did a good job, lol. You shouldnt see my psd files and ive been working in photoshop for over 11 years...

Who mentioned photoshop? I just meant instead of this...

HotKeySet("{F4}", "quit")
HotKeySet("{F2}", "pause")

Func quit()
Exit
EndFunc

$ison = 1
Func pause()
$ison = NOT $ison
Endfunc

While 1
If $ison Then
MouseClick("left")
Sleep(1000)
MouseClick("left")
sleep(1000)
EndIf
WEnd

Make it like this...

HotKeySet("{F4}", "quit")
HotKeySet("{F2}", "pause")

Func quit()
    Exit
EndFunc

$ison = 1
Func pause()
    $ison = NOT $ison
Endfunc

While 1
    If $ison Then
        MouseClick("left")
        Sleep(1000)
        MouseClick("left")
        sleep(1000)
    EndIf
WEnd

#2 Has to click twice, a dubbleclick would work, but i never looked at it again after the first working version.

I mean that logically...

While 1
    If $ison Then
        MouseClick("left")
        Sleep(1000)
        MouseClick("left")
        sleep(1000)
    EndIf
WEnd

Is the same as...

While 1
    If $ison Then
        MouseClick("left")
        sleep(1000)
    EndIf
WEnd

Except that in your version if they press pause after the 1st click, the 2nd click will still happen before the pause.

#3 It were for the testing, i didnt want to have rapid clicking all over, should be at 100, if it goes lower than 50 the game will shut down (or so they say)

Okay. Also should mention that the sleep should be outside the If statement. Otherwise when they script is paused it will run the CPU up from a no delay infinite loop.

#4 Ya, But ive not experienced enough, the functions is only called, so i have to make some pause until the key for the pause key is pushed BEFORE $ison = 1 (lol sorry couldnt resist) , working on it right away!

Not sure what your saying here but wouldn't it be better to start your script, enter the program you want to use it on, then hit F2 to start whenever you want so you won't have to add any extra pauses. Basically you think in terms of it being on and telling it when to stop/restart. I think in terms of it being off and telling it when to start/stop. Just a different default state to make things easier.

#5 my friend wrote that part of the code, so i didnt dare to touch it nor know how it worked, but i guess its all the 1s that could be changed to True instead, and yes i agree with you.

If interested here is my version of this type of program that I wrote a while ago and use occasionally. It follows the same idea as the one you have.

HotKeySet("{F1}","Go")
HotKeySet("{ESC}","Terminate")
Global $click = False
While True
    sleep(10)
    If $click = True Then MouseClick("left")
WEnd
Func Go()
    $click = Not $click
EndFunc
Func Terminate()
    Exit
EndFunc

Still dosnt solve the third mousebutton key :/ its all ok as it is but i want perfection and thanks to you i got another thing fixed!

You cannot assign mouse buttons to hotkeys but you can check for them. Unfortunately I'll explain why you cant use it for this case. Normally to make something that happens off a middle mouse click you might use this...

#include <Misc.au3>
$dll = DllOpen("user32.dll")
HotKeySet("{ESC}","Terminate")
Func Terminate()
    Exit
EndFunc
Global $click = False
While True
    Sleep(10)
    If _IsPressed("04", $dll) Then $click = Not $click
    If $click = True Then MouseClick("left")
WEnd

The problem is that having MouseClick click a button while you are phsically holding a button screws up the ability for _IsPressed to be accurate. Two things can happen. If you are holding the same button MouseClick sends a click for, then it will make _IsPressed think you released the button. For example if you test _IsPressed for the left click and then MouseClick("left"). It will think you released the left mouse button even if you didn't. But in your case if you Press the middle button and then AutoIt sends a MouseClick("left") before you can release it. It will cause _IsPressed to think you never released the middle button. Which in my example will never let you stop clicking. Hope that was clear enough.

Edited by ShawnW
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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