Sign in to follow this  
Followers 0
Pharon

Multicolor clicker

8 posts in this topic

HotKeySet("=", "MyExit")
HotKeySet("[", "MyStop")
HotKeySet("-", "MyStart")

Do
Until 0

Func MyStart()
$s = 1
Do
If $s = 1 Then
$coord = PixelSearch( 359, 378, 748, 379, 0x219988 )
If @error Then
$s = $s + 1
Else
MouseMove ( $coord[0], $coord[1] , 0 )
EndIf

If $s = 2 Then
$coord = PixelSearch( 359, 378, 748, 379, 0x020380 )
If @error Then
$s = $s + 1
Else
MouseMove ( $coord[0], $coord[1] , 0 )
EndIf

If $s = 3 Then
$coord = PixelSearch( 359, 378, 748, 379, 0x818507 )
If @error Then
$s = $s + 1
Else
MouseMove ( $coord[0], $coord[1] , 0 )
EndIf

If $s = 4 Then
$coord = PixelSearch( 359, 378, 748, 379, 0x9E9E9E )
If @error Then
$s = 1
Else
MouseMove ( $coord[0], $coord[1] , 0 )
EndIf
Until $s = 99
EndFunc

Func MyStop()
   $s = 99 
EndFunc

Func MyExit()
   Exit 
EndFunc

Well, I tried to make it detect a color then put the mouse to it, but for some reason every time I run it I get a error saying that "Until $s = 99" has no matching Do statement, but there is one right at the begining.

I know this is in my color post, but I started to think that I was getting off topic in my own thread so I started a new one. Plus with it being the first post it might get me some answers...

Share this post


Link to post
Share on other sites



this is what tidy says... does that help ?:

HotKeySet("=", "MyExit")
HotKeySet("[", "MyStop")
HotKeySet("-", "MyStart")
Do
Until 0
Func MyStart()
   $s = 1
   Do
      If $s = 1 Then
         $coord = PixelSearch(359, 378, 748, 379, 0x219988)
         If @error Then
            $s = $s + 1
         Else
            MouseMove($coord[0], $coord[1], 0)
         EndIf
         If $s = 2 Then
            $coord = PixelSearch(359, 378, 748, 379, 0x020380)
            If @error Then
               $s = $s + 1
            Else
               MouseMove($coord[0], $coord[1], 0)
            EndIf
            If $s = 3 Then
               $coord = PixelSearch(359, 378, 748, 379, 0x818507)
               If @error Then
                  $s = $s + 1
               Else
                  MouseMove($coord[0], $coord[1], 0)
               EndIf
               If $s = 4 Then
                  $coord = PixelSearch(359, 378, 748, 379, 0x9E9E9E)
                  If @error Then
                     $s = 1
                  Else
                     MouseMove($coord[0], $coord[1], 0)
                  EndIf
;### Tidy Error: Level error -> Until is closing previous If
               Until $s = 99
;### Tidy Error: Level error -> EndFunc is closing previous If
            EndFunc  ;==>MyStart
;### Tidy Error: Level error -> "If" Not closed before Func statement.
;### Tidy Error: Level error -> "Func" cannot be inside any IF/Do/While/For/Case/Func statement.
            Func MyStop()
               $s = 99
            EndFunc  ;==>MyStop
;### Tidy Error: Level error -> "If" Not closed before Func statement.
;### Tidy Error: Level error -> "Func" cannot be inside any IF/Do/While/For/Case/Func statement.
            Func MyExit()
               Exit
            EndFunc  ;==>MyExit

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

What a mess. You should more careful closing While/Wend, If/EndIf, ect.

I advice you writing, when you create a new loop or if, also the closing tag. So you'll have a more sorted idea.

So, you need an If? Write

If
  ;Continue here
EndIf

a While?

While
  ;Continue here
Wend

Secondly a

Do
Until 0

is not advised since your script will maximize your CPU for nothing. Use a pause.

Do
Sleep(1000)
Until 0

Finally indent as much you can. It becomes lots easier to detect loops/if errors.

(jdeb went straight in that idea!)

Scite for Autoit have Tidy, a great Jdeb's program, that will make that for you.

Code, code, code... You need think a little? Press CTRL+9, while you think the computer will tidy the code.

Edited by ezzetabi

Share this post


Link to post
Share on other sites

Do
     If $s = 1 Then
        $coord = PixelSearch(359, 378, 748, 379, 0x219988)
        If @error Then
           $s = $s + 1
        Else
           MouseMove($coord[0], $coord[1], 0)
        EndIf

So instead of that I want to move the EndIf to before else?

Do
     If $s = 1 Then
        $coord = PixelSearch(359, 378, 748, 379, 0x219988)
        If @error Then
           $s = $s + 1
        EndIf
        Else
           MouseMove($coord[0], $coord[1], 0)

like that?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Do
      If $s = 1 Then
         $coord = PixelSearch(359, 378, 748, 379, 0x219988)
         If @error Then
            $s = $s + 1
         Else
            MouseMove($coord[0], $coord[1], 0)
         EndIf
      EndIf
      If $s = 2 Then
...... etc

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Anyway, I guess you meant

HotKeySet("=", "MyExit")
HotKeySet("[", "MyStop")
HotKeySet("-", "MyStart")

Do
   Sleep(1000)
Until 0

Func MyStart()
   $s = 1
   Do
      If $s = 1 Then
         $coord = PixelSearch(359, 378, 748, 379, 0x219988)
         If @error Then
            $s = $s + 1
         Else
            MouseMove($coord[0], $coord[1], 0)
         EndIf
      ElseIf $s = 2 Then
         $coord = PixelSearch(359, 378, 748, 379, 0x020380)
         If @error Then
            $s = $s + 1
         Else
            MouseMove($coord[0], $coord[1], 0)
         EndIf
      ElseIf $s = 3 Then
         $coord = PixelSearch(359, 378, 748, 379, 0x818507)
         If @error Then
            $s = $s + 1
         Else
            MouseMove($coord[0], $coord[1], 0)
         EndIf
         
      ElseIf $s = 4 Then
         $coord = PixelSearch(359, 378, 748, 379, 0x9E9E9E)
         If @error Then
            $s = 1
         Else
            MouseMove($coord[0], $coord[1], 0)
         EndIf
      EndIf
   Until $s = 99
EndFunc  ;==>MyStart


Func MyStop ()
   $s = 99
EndFunc  ;==>MyStop 

Func MyExit ()
   Exit
EndFunc  ;==>MyExit

Share this post


Link to post
Share on other sites

Gah, I can't believe I didn't notice thouse other if statements in my code x.x I see what you were saying now, I just didn't realize I didn't end thouse...

Share this post


Link to post
Share on other sites

Always happy to help.

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