Sign in to follow this  
Followers 0
csergiu

Help with a simple autoclicker

4 posts in this topic

#1 ·  Posted (edited)

Hey, I'm new to AutoIt (so I'm kind of a n00b :D) and I'm trying to make an autoclicker. I need it to left click once every 9 minutes, I have done this by now but I can't figure out why it doesn't work.

MsgBox(0, "information here...")
 
HotKeySet("{F9}", "startclick")
HotkeySet("{F11}", "HK_STOP")
 
; functia click
Func startclick()
; infinite loop for left click
while(1)
Sleep(20)
MouseClick("left")
WEnd
EndFunc
 
; stop click
Func HK_STOP()
while 1 = 1
  Sleep(50)
wend
EndFunc
 
; keep the program running
while(1)
sleep(50)
WEnd

That is working, it continuously clicks but with some pauses (I don't know why) and if I set Sleep(20) to Sleep(540000) it doesn't work. It just clicks once and then after I wait 540000 ms it doesn't click again. Or if I put Sleep(2000) or Sleep(5000) it clicks but with longer breaks (what I mean is: clicks a couple of times every 2 or 5 seconds and then it stops for a while and starts again).

I don't know if you can understand what I'm saying, but I need this for a project for school... please help!

Edited by csergiu

Share this post


Link to post
Share on other sites



You need some type of if statement and compare _Timer_Init() and _Timer_Diff()


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

csergui,

For starters, your call to msgbox is wrong. How are you getting this to run?

Secondly, you may want to consider using "adlib" type processing (see help file) for your functions. Also, guiacellerators limit key scope to your script (with hotkey's the scope is global). Again, see help file.

Good Luck!!

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I'm not sure why your code doesn't function properly (aside from the above comment), but this is another way to achieve the same goal using some different concepts. I didn't run this, but you get the idea. This code will run indefinitely. When a user presses F9, it will click once and pause for 9 minutes. How it's written, if they press F11 then F9 again while in the 9 minute wait, it will not respond to anything until the wait is up.

If you want it to be able to stop its wait and restart, consider using a for loop that sleeps for the same amount of time, each iteration should check if your shared $click is changing.

MsgBox(0, "", "information here...")
;shared variable
Global $click = false
HotKeySet("{F9}", "startclick")
HotkeySet("{F11}", "HK_STOP")
 
; functia click
Func startclick()
$click = true
EndFunc
 
; stop click
Func HK_STOP()
$click = false
EndFunc
 
; keep the program running
while(1)
sleep(50)
    While ($click=true)
        mouseclick("left")
        sleep(9*60*1000)
    WEnd
WEnd
Edited by pacman1176

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