Need help with pixel detection reaction
Posted: 07 Mar 2018, 00:58
Hi guys, I'm new to ahk and trying to make a script that detects a pixel changes and terminate a process if that pixel has not changed for a certain amount of time. So far, it's been able to detect the pixel and terminate the process thatI wanted but there are 2 problems that I'm having right now.
[*]The script terminates itself after process termination (I worked around this but using Run but I'm sure there's a more elegant way to do this lol)
[*]The pixel that it detects may not be on the correct window, I guess its the static background window so it will kill the wanted process anyway regardless of pixel changes. (I tried different CoordMode but still, the problem remains)
Here's my script:
Hope you guys can help me fix those 2 problems that I'm having, thank you and have a great day guys!
[*]The script terminates itself after process termination (I worked around this but using Run but I'm sure there's a more elegant way to do this lol)
[*]The pixel that it detects may not be on the correct window, I guess its the static background window so it will kill the wanted process anyway regardless of pixel changes. (I tried different CoordMode but still, the problem remains)
Here's my script:
Code: Select all
CoordMode, Pixel, Relative ;<-- forces the Pixel commands to use relative mode
; this will cause the coordinates to move around based on what window is active
; and where the window is on the screen
;CoordMode, Pixel, Screen ;<-- forces the pixel commands to use the full screen.
; In this mode the coordinates will be locked to the entire screen area and whatever
; window is under that screen location will be used for the color comparison.
While (GetColor(thisColor) = GetColor(thatColor))
continue
;Process,Close, vlc.exe
Run, "C:\Users\Bill\Desktop\script.exe"
Return
GetColor(X)
{
PixelGetColor, X, 351, 298
sleep 1000
Return X
}