Jump to content

Recommended Posts

Posted

Can anyone tell me what i am doing wrong?

#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
Posted (edited)

and what do you try to do?

MouseClick Syntaxis:

  Quote

MouseClick ( "button" [, x, y [, clicks [, speed ]]] )

Edited by P0ZiTR0N
Posted (edited)

  Scoboose said:

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 by mdiesel
Posted (edited)

Look in the help file; there is an example of a toggle. You are not understanding how the program flows.

Edited by qazwsx
  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

Posted

"Try this:"

its mine just starts activated.

@Scoboose

Please 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 well

MDiesel

Posted

  Melba23 said:

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
Posted (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 by Scoboose
  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

Posted (edited)

  Melba23 said:

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 by Scoboose
Posted

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
  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

Posted

  Melba23 said:

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

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
  • Recently Browsing   0 members

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