Pixel Search>Playing sound

Ask gaming related questions (AHK v1.1 and older)
Dosu
Posts: 2
Joined: 18 Mar 2018, 10:16

Pixel Search>Playing sound

18 Mar 2018, 10:54

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.
gregster
Posts: 9002
Joined: 30 Sep 2013, 06:48

Re: Pixel Search>Playing sound

18 Mar 2018, 14:37

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?
Dosu
Posts: 2
Joined: 18 Mar 2018, 10:16

Re: Pixel Search>Playing sound

18 Mar 2018, 18:14

Thank you for reply. I think i figured out. I changed Return for Continue and deleted comma. Seems like everything working fine now.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 51 guests