Sign in to follow this  
Followers 0
briancd2

Auto Clicker Issues

7 posts in this topic

#1 ·  Posted (edited)

I'm brand new to coding, always been fascinated with it, and I can't seem to get this auto-clicker to work for me. Whenever I try to run the code, it gives me an error for lines 9 and 29.

MsgBox(0, "Welcome", "This program was made by briancd2.")

Func Change()
   Global $clicker = InputBox("", "How many clicks would you like to send?", "100")
   Global $switch = InputBox("", "Left(1) or Right(2) click?", "2")
EndFunc

Func hotkeys()
   MsgBox(0, "Hotkeys", "Press F6 to pause. Press F7 to begin. F8 to end the program. F9 to change clicks and right/left click. F10 to reopen this."
EndFunc

If Change() = True Then
  begin()
EndIf

hotkeys()

If $switch = 1 Then 
   $switcher = "left"
ElseIf $switch = 2 Then
   $switcher = "right"
Else
   $switch > 2 Then
   MsgBox(0, "", "Change your click to Left(1) or Right(2).")
   Change()
EndIf
   
Func click()
   MouseClick($switch,(,($clicker,(0))))
   Sleep(500)
   change()
EndFunc

Func begin()
   While 1
 click()
   WEnd
EndFunc

Func Terminate()
   Exit 0
EndFunc

Func Pause()
   MsgBox(0,"Pause", "Press Ok when you're ready to resume.")
   Sleep(1500)
EndFunc

HotKeySet("{F7}", "begin")
HotKeySet("{F8}", "Terminate")
HotKeySet("{F6}","Pause")
HotKeySet("{F9}", "change")
HotKeySet("{F10}", "hotKey")

While 1
   Sleep(1)
WEnd
 
I honestly have no idea what I've done wrong; however, this is one of the only scripts I've made, so I wouldn't know what was wrong anyways.
Edited by briancd2

Share this post


Link to post
Share on other sites



Hi Brian,

 and welcome to the forum! It looks like you've been pretty busy there.

I would suggest that get a simple hotkey set working and then get each individual funtion working on its own and then put them together.

BTW there are more mistakes in your scrpt than just those 2 ;-)

Here is something to get you started:

HotKeySet("{F5}", "_f5") ;Scenario 1
HotKeySet("{F6}", "_f6") ;Scenario 2

Run("notepad.exe") ; to test
WinSetState("[CLASS:Notepad]", "", @SW_HIDE)

While 1
    Sleep(28800)
WEnd

;F5 Scenario 1
Func _f5()

        WinSetState("[CLASS:Notepad]", "", @SW_MAXIMIZE)

EndFunc

;F6 Scenario 2
Func _f6()

        WinSetState("[CLASS:Notepad]", "", @SW_MINIMIZE)

EndFunc

Good luck!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Welcome to Autoit  briancd2

Use ControlClick instead of MouseClick it is more accurate.

Edited by adnanbaloch

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I looked at what you showed me and I couldn't relate it to what I was attempting to do, but I found out how to fix my problem. I actually feel very dumb right now.

 

Func Bind()
   MsgBox(0, "Welcome", "F6 to pause. F7 to end the program. F8 to start. F9 to open this window.")
EndFunc

Func Terminate()
   Exit 0
EndFunc

Func Pause()
   MsgBox(0,"Pause", "Press Ok when you're ready to resume.")
   Sleep(1500)
EndFunc

Func Begin()
   While 1
      MouseClick("")
   WEnd
EndFunc

HotKeySet("{F6}", "Pause")
HotKeySet("{F7}", "Terminate")
HotKeySet("{F8}", "Begin")
HotKeySet("{F9}", "Bind")

Bind()

While 1
   Sleep(1)
WEnd
Edited by briancd2

Share this post


Link to post
Share on other sites

Glad you got it working !

The code I posted was just an example to get you started in the right direction as your code was kinda messy ;-)

Even the code you have now, although it may work, is upside down. The Function calls, includes, while loops are notoriously positioned at the top.

Helps keep things neat and easy to find when your script gets bigger.

Anyway, good luck with your script...

Bill

Share this post


Link to post
Share on other sites

briancd2, my first question is what program do you try to automate? Clicks are usually pretty unreliable; there is often a much better way to accomplish what you seek.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Whenever I make a new script for anything, it's usually just to replace my own original method of doing things. The auto-clicker was me attempting to make something that could replace my other clicker even though I could have just easily downloaded another. Most scripts I make are for enjoyment; however, I originally wanted to learn Java and gave up on it pretty fast, so I see this as a gateway to simple coding.

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