briancd2 Posted October 20, 2013 Posted October 20, 2013 (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. expandcollapse popupMsgBox(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 November 3, 2013 by briancd2
Solution l3ill Posted October 20, 2013 Solution Posted October 20, 2013 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! My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
Starstar Posted October 20, 2013 Posted October 20, 2013 (edited) Welcome to Autoit briancd2 Use ControlClick instead of MouseClick it is more accurate. Edited October 20, 2013 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."
briancd2 Posted November 3, 2013 Author Posted November 3, 2013 (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 November 3, 2013 by briancd2
l3ill Posted November 3, 2013 Posted November 3, 2013 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 My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
Moderators JLogan3o13 Posted November 4, 2013 Moderators Posted November 4, 2013 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. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
briancd2 Posted November 9, 2013 Author Posted November 9, 2013 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now