Page 1 of 1

Pixel Search>Playing sound

Posted: 18 Mar 2018, 10:54
by Dosu
Hello i need some help with my first script. The idea is: searching pixel in cycle in given coordinates, if pixel found, then playing sound in cycle until for example "END" key pressed. First i tried with simple PixelSearch example:

Code: Select all

CoordMode, Pixel, Screen
PixelSearch, Px, Py, 162, -659, 289, -329, 0x040493, 3, Fast
if ErrorLevel
    MsgBox, That color was not found in the specified region.
else
    MsgBox, A color within 3 shades of variation was found at X%Px% Y%Py%.
And everything works fine. But when i start digging with Loop function i'm confused. For example:

Code: Select all

Loop
{
Sleep 1000
CoordMode, Pixel, Screen
PixelSearch, Px, Py, 162, -659, 289, -329, 0x040493, 3, Fast
if ErrorLevel, 
Return
else
SoundPlay *-1
}
Esc::ExitApp
This script playing sound every 1 second right after start even if pixel not found. I think i messed something with if ErrorLevel, Return commands but cant understand how. Thank you for any help.

Re: Pixel Search>Playing sound

Posted: 18 Mar 2018, 14:37
by gregster
Why did you add a comma after Errorlevel? I don't think that can work.
Also, what is the goal of that return? Where should it return to?

Re: Pixel Search>Playing sound

Posted: 18 Mar 2018, 18:14
by Dosu
Thank you for reply. I think i figured out. I changed Return for Continue and deleted comma. Seems like everything working fine now.