-1

I am self learning programmer, and been struggling with this issue for a while. I would be really happy if someone could point me to the right direction.

What I had: A perfectly working pixelsearch1 autoit script. What I want to achieve: put that code into an another pixelsearch2. So if pixelsearch2 not error then proceed with pixelsearch1, else do other stuff.

My pixelsearch2 works fine without pixelsearch1. It recognises the color and both the not error end else statement works. However if I put the pixelsearch1 to the not error part, the pixelsearch1 won't work.

So this is my perfectly working pixelsearch1 function:

Func pixelSearch1()
    $search = PixelSearch(106, 789, 108, 787, 0xDB0040, 5)
      If Not @error Then
         MouseMove($search[0], $search[1], 0)
         Sleep(100)
         Send("A")
      EndIf
EndFunc

And this is where the pixelsearch1 not working:

While 1

PixelSearch(330, 780, 332, 782, 0x8C30C9, 5)

If Not @error Then

      pixelSearch1()

Else
      ;some other stuff which works
Endif
WEnd

Please note that if I put anything else between "If Not @error Then" - "Else", then it is working.

Arnoux
  • 19
  • 3

1 Answers1

0

I could solve the problem, by updating the first function, with different tabs and putting a sleep between endif and endfunc.

I have no idea why is it working now and not previously, but it works.

Arnoux
  • 19
  • 3
  • 1
    You must have a sleep in while infinite loop as best practice. Otherwise many user-simulation functions will not work and you will have cpu overload. – matrix Oct 09 '17 at 10:39