Jump to content


Photo

AHK_L, PixelSearch, and 'fast' parameter


  • Please log in to reply
1 reply to this topic

#1 Leef_me

Leef_me
  • Moderators
  • 7704 posts

Posted 08 September 2012 - 06:41 PM

AHK_L version 1.1.07.03
Problem is still present in version 1.1.08.00

Using Pixelsearch, the 'fast' parameter gives errorlevel=2 (instead of expected 1) if no match is found

PixelSearch, OutputVarX, OutputVarY, x,y,x,y, DesiredColor, 5, Fast


Below is a script & results that display the problem.
<!-- l --><a class="postlink-local" href="http://www.autohotkey.com/community/viewtopic.php?p=557239#p557239">viewtopic.php?p=557239#p557239</a><!-- l -->


I use both AHK-basic and AHK_L. I use AHL suffix for AHK_L scripts and AHK for AHK_basic scripts.

It appears that the err= 2 is caused by 'fast' using AHK_L, when the colors don't match.
If I run this same exact script with ahk_basic, the '2' become '1'
It would seem to be a bug in AHK_L
DesiredColor = 0x707070
OtherColor = 0xB07070

CoordMode, ToolTip, screen
CoordMode, Pixel, screen
CoordMode, Mouse, screen

x = 100
y = 100

result := A_ScriptName "  version " A_AhkVersion "`r`r" 

backgroundcolor := DesiredColor

gui, destroy
gui, color, %backgroundcolor%

result .= "background is " backgroundcolor "`r"
result .= "DesiredColor " DesiredColor  

gui, -Caption
gui, show, w%A_ScreenWidth% h%A_ScreenHeight%

 

 PixelGetColor, color, X, Y 

 PixelSearch, OutputVarX, OutputVarY, x,y,x,y, DesiredColor, 5, Fast
 err_5_fast := errorlevel

 PixelSearch, OutputVarX, OutputVarY, x,y,x,y, DesiredColor, 0, Fast
 err_0_fast := errorlevel

 PixelSearch, OutputVarX, OutputVarY, x,y,x,y, DesiredColor, 5, 
 err_5____ := errorlevel

 PixelSearch, OutputVarX, OutputVarY, x,y,x,y, DesiredColor, 
 err_0___ := errorlevel

 result .= "`rPixelGetColor " color "`rerr_5_fast= " err_5_fast "`rerr_0___= " err_0___
 result .= "`rerr_5____= " err_5____ "`rerr_0_fast= " err_0_fast

;==============================================================
 result .= "`r`r"
sleep, 1000
;==============================================================
backgroundcolor := OtherColor

gui, destroy
gui, color, %backgroundcolor%

result .= "background is " backgroundcolor "`r"
result .= "DesiredColor " DesiredColor  

gui, -Caption
gui, show, w%A_ScreenWidth% h%A_ScreenHeight%

 PixelGetColor, color, X, Y 

 PixelSearch, OutputVarX, OutputVarY, x,y,x,y, DesiredColor, 5, Fast
 err_5_fast := errorlevel

 PixelSearch, OutputVarX, OutputVarY, x,y,x,y, DesiredColor, 0, Fast
 err_0_fast := errorlevel

 PixelSearch, OutputVarX, OutputVarY, x,y,x,y, DesiredColor, 5, 
 err_5____ := errorlevel

 PixelSearch, OutputVarX, OutputVarY, x,y,x,y, DesiredColor, 
 err_0___ := errorlevel

 result .= "`rPixelGetColor " color "`rerr_5_fast= " err_5_fast "`rerr_0___= " err_0___
 result .= "`rerr_5____= " err_5____ "`rerr_0_fast= " err_0_fast

sleep, 1000
gui, destroy

msgbox % result

Return



Return
junk2681a.ahl  version 1.1.07.03

background is 0x707070
DesiredColor 0x707070
PixelGetColor 0x707070
err_5_fast= 0
err_0___= 0
err_5____= 0
err_0_fast= 0

background is 0xB07070
DesiredColor 0x707070
PixelGetColor 0x7070B0
err_5_fast= 2
err_0___= 1
err_5____= 1
err_0_fast= 2


#2 Lexikos

Lexikos
  • Administrators
  • 8853 posts

Posted 09 September 2012 - 05:46 AM

I believe this error was introduced by this change, part of support for exception handling (v1.1.04). It will be fixed in the next release.