Scoboose Posted April 20, 2009 Share Posted April 20, 2009 Can anyone tell me what i am doing wrong? expandcollapse popup#cs ---------------------------------------------------------------------------- Esc - Quits #ce ---------------------------------------------------------------------------- Global $neverendloop = -1 Dim $a HotKeySet("{ESC}", "Terminate") HotKeySet("n", "Toggle") While 1 Sleep(1000) MsgBox(0, "Info", "Just a simple clicker ") Do Sleep(1000) Until $neverendloop > 1 Sleep(1000) WEnd $a = 2 ; Toggle run/pause Func Toggle() If $a = 1 Then $a = 2 Else $a = 1 EndIf EndFunc While $a = 1 MouseClick("Left") Sleep(1000) WEnd Func Terminate() Exit 0 EndFunc Link to comment Share on other sites More sharing options...
P0ZiTR0N Posted April 20, 2009 Share Posted April 20, 2009 (edited) and what do you try to do? MouseClick Syntaxis: MouseClick ( "button" [, x, y [, clicks [, speed ]]] ) Edited April 20, 2009 by P0ZiTR0N Link to comment Share on other sites More sharing options...
Scoboose Posted April 20, 2009 Author Share Posted April 20, 2009 trying to make it so when i press "n" it will click every sec until i press "n" again So "n" turns it on and off Link to comment Share on other sites More sharing options...
Mat Posted April 20, 2009 Share Posted April 20, 2009 (edited) Can anyone tell me what i am doing wrong? While $a = 1 MouseClick("Left") Sleep(1000) WEnd here it runs through and ends.... should be more like While 1 If $a = 1 Then MouseClick("Left") Sleep(1000) WEnd I end up with a full code more like this: HotKeySet("{ESC}", "Terminate") HotKeySet("n", "Toggle") MsgBox(0, "Info", "Just a simple clicker ") $a = 2 While 1 If $a = 1 Then MouseClick("Left") Sleep(1000) WEnd Func Toggle() If $a = 1 Then $a = 2 Else $a = 1 EndIf EndFunc Func Terminate() Exit 0 EndFunc Edited April 20, 2009 by mdiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
Scoboose Posted April 20, 2009 Author Share Posted April 20, 2009 That just makes it run once Link to comment Share on other sites More sharing options...
qazwsx Posted April 20, 2009 Share Posted April 20, 2009 (edited) Look in the help file; there is an example of a toggle. You are not understanding how the program flows. Edited April 20, 2009 by qazwsx Link to comment Share on other sites More sharing options...
Mat Posted April 20, 2009 Share Posted April 20, 2009 (edited) ...no it doesn't... while 1 is a neverending loop. try it. mine works exactly as you want it to. Edited April 20, 2009 by mdiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
Scoboose Posted April 20, 2009 Author Share Posted April 20, 2009 ...no it doesn't...while 1 is a neverending loop.try it. mine works exactly as you want it to.Thank you Link to comment Share on other sites More sharing options...
Jfish Posted April 20, 2009 Share Posted April 20, 2009 Thank youTry this:CODEHotKeySet("{ESC}", "Terminate")HotKeySet("n", "Toggle")MsgBox(0, "Info", "Just a simple clicker ") $a = 1While 1 If $a = 1 Then MouseClick("Left") Sleep(1000) Else Terminate() EndIfWEndFunc Toggle()If $a = 1 Then $a = 2Else $a = 1 EndIfEndFuncFunc Terminate() Exit 0EndFunc Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 20, 2009 Moderators Share Posted April 20, 2009 Scoboose, Using a Boolean variable makes the toggle much simpler:#cs ---------------------------------------------------------------------------- Esc - Quits #ce ---------------------------------------------------------------------------- Global $fToggle = True HotKeySet("{ESC}", "Terminate") HotKeySet("n", "Toggle") While 1 While $fToggle ConsoleWrite("MouseClick " & @SEC & @CRLF); In place of MouseClick("Left") Sleep(1000) WEnd WEnd ; Toggle run/pause Func Toggle() $fToggle = Not $fToggle ; <<<<<<<<<<<< really simple syntax! EndFunc ;==>Toggle Func Terminate() Exit EndFunc ;==>Terminate M23 psbeau 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Mat Posted April 20, 2009 Share Posted April 20, 2009 "Try this:"its mine just starts activated.@ScoboosePlease test before answering in the future... I've done it before too, and its not pretty. It usually ends up with you being proved wrong by someone, which is not good.Theres also always someone to come out with a better method right at the end...***Melba23***hope it goes wellMDiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
Scoboose Posted April 20, 2009 Author Share Posted April 20, 2009 Scoboose, Using a Boolean variable makes the toggle much simpler:#cs ---------------------------------------------------------------------------- Esc - Quits #ce ---------------------------------------------------------------------------- Global $fToggle = True HotKeySet("{ESC}", "Terminate") HotKeySet("n", "Toggle") While 1 While $fToggle ConsoleWrite("MouseClick " & @SEC & @CRLF); In place of MouseClick("Left") Sleep(1000) WEnd WEnd ; Toggle run/pause Func Toggle() $fToggle = Not $fToggle; <<<<<<<<<<<< really simple syntax! EndFunc ;==>Toggle Func Terminate() Exit EndFunc ;==>Terminate M23 I don't understand any of that lol. sorry Link to comment Share on other sites More sharing options...
Scoboose Posted April 20, 2009 Author Share Posted April 20, 2009 (edited) What if i want it to do more then just left click? this will continue to press "c" and i don't want it to Dim $a HotKeySet("{ESC}", "Terminate") HotKeySet("n", "Toggle") MsgBox(0, "Info", "Press the N key to toggle Gathering. Press Esc to quit macro. ") $a = 2 While 1 If $a = 1 Then MouseClick("left") Sleep(125) Send("c") sleep(1000) WEnd Func Toggle() If $a = 1 Then $a = 2 Else $a = 1 EndIf EndFunc Func Terminate() Exit 0 EndFunc Edited April 20, 2009 by Scoboose Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 20, 2009 Moderators Share Posted April 20, 2009 Scoboose,OK, a Boolean variable can only be 'True' or 'False' - which for a toggle is just what you want. So the 'Toggle' function changes the value of the $fToggle variable by using Not:Not True = FalseNot False = TrueEasy, no?Here is a commented version:; Set the toggle to True Global $fToggle = True HotKeySet("{ESC}", "Terminate") HotKeySet("n", "Toggle") While 1 While $fToggle; If the toggle is True then do this - if it is False then do not You could also write 'If $fToggle = True' here - it means the same thing ConsoleWrite("MouseClick " & @SEC & @CRLF); In place of MouseClick("Left") Sleep(1000) WEnd WEnd ; Toggle run/pause Func Toggle() $fToggle = Not $fToggle ; Change the toggle as explained above EndFunc;==>Toggle Func Terminate() Exit EndFunc;==>TerminateBoolean variables are not easy to understand, but are well worth the trouble as they can really make your life easy in certain circumstances - like toggles! :-)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Scoboose Posted April 20, 2009 Author Share Posted April 20, 2009 (edited) Scoboose, OK, a Boolean variable can only be 'True' or 'False' - which for a toggle is just what you want. So the 'Toggle' function changes the value of the $fToggle variable by using Not: Not True = False Not False = True Easy, no? Here is a commented version:; Set the toggle to True Global $fToggle = True HotKeySet("{ESC}", "Terminate") HotKeySet("n", "Toggle") While 1 While $fToggle; If the toggle is True then do this - if it is False then do not You could also write 'If $fToggle = True' here - it means the same thing ConsoleWrite("MouseClick " & @SEC & @CRLF); In place of MouseClick("Left") Sleep(1000) WEnd WEnd ; Toggle run/pause Func Toggle() $fToggle = Not $fToggle; Change the toggle as explained above EndFunc;==>Toggle Func Terminate() Exit EndFunc;==>Terminate Boolean variables are not easy to understand, but are well worth the trouble as they can really make your life easy in certain circumstances - like toggles! :-) M23 Ok i sort if get it so a Boolean variable is like a on off switch it can only be on or off, right? and $fToggle = Not $fToggle means change it from what it is to what it is not, right? now what is all this? ConsoleWrite("MouseClick " & @SEC & @CRLF); In place of MouseClick("Left") sorry i am new the whole scripting thing but i like to think i can learn Edited April 20, 2009 by Scoboose Link to comment Share on other sites More sharing options...
Scoboose Posted April 20, 2009 Author Share Posted April 20, 2009 Hey i got it Thank you guys HotKeySet("{ESC}", "Terminate") HotKeySet("n", "Toggle") Global $fToggle = False While 1 While $ftoggle = True MouseClick("left") Sleep(125) Send("c") sleep(1000) WEnd WEnd Func Toggle() $ftoggle = Not $ftoggle EndFunc Func Terminate() Exit 0 EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 20, 2009 Moderators Share Posted April 20, 2009 Scoboose,ConsoleWrite("MouseClick " & @SEC & @CRLF); In place of MouseClick("Left")ConsoleWrite sends text to the lower window of SciTE - here it is sending the word "MouseClick" followed by the actual msec count so you can see that the MouseClicks are different and happen once a second.; begins a comment - everything after it is ignored by AutoIt. So I can tell you that I am using this line in place of your MouseClick (basically because you cannot see a mouse click!) and Autoit does not think I am trying to tell it something instead.If you are very new to scripting with Autoit, reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Scoboose Posted April 20, 2009 Author Share Posted April 20, 2009 Scoboose, ConsoleWrite("MouseClick " & @SEC & @CRLF); In place of MouseClick("Left") ConsoleWrite sends text to the lower window of SciTE - here it is sending the word "MouseClick" followed by the actual msec count so you can see that the MouseClicks are different and happen once a second. ; begins a comment - everything after it is ignored by AutoIt. So I can tell you that I am using this line in place of your MouseClick (basically because you cannot see a mouse click!) and Autoit does not think I am trying to tell it something instead. If you are very new to scripting with Autoit, reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here. M23 TYVM Link to comment Share on other sites More sharing options...
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