ConfirmDesiredPixelAtLocation(Flag, WindowTitle, X, Y, DesiredColor, LocationComment, LoopTime)
{
;transform the coordinates from 1680 x 1050 resolution to current screen resolution
X := X//(1680/A_ScreenWidth)
Y := Y//(1050/A_ScreenHeight)
Xmin := X-2
Xmax := X+2
Ymin := Y-2
Ymax := Y+2
EndTime := A_TickCount+LoopTime+1
ClipBoard =
ClipBoard = %ClipBoard% X = %X% `r`n
ClipBoard = %ClipBoard% Y = %Y% `r`n
ClipBoard = %ClipBoard% Xmin = %Xmin% `r`n
ClipBoard = %ClipBoard% Xmax = %Xmax% `r`n
ClipBoard = %ClipBoard% Ymin = %Ymin% `r`n
ClipBoard = %ClipBoard% Ymax = %Ymax% `r`n
ClipBoard = %ClipBoard% LoopTime = %LoopTime% `r`n
ClipBoard = %ClipBoard% DesiredColor = %DesiredColor% `r`n
ClipBoard = %ClipBoard% EndTime = %Endtime% `r`n
ClipBoard = %ClipBoard% `r`n
While A_TickCount<EndTime
{
PixelSearch, OutputVarX, OutputVarY, Xmin, Ymin, Xmax, Ymax, DesiredColor, 5, Fast
If ErrorLevel=0
{
Return 0
}
Sleep 10
}
If (Flag=1 and ErrorLevel=1)
{
Return 1
}
Else If (Flag=0 and ErrorLevel=1)
{
WinGetActiveTitle, CurrentTitle
MouseMove, X, Y
;ClipBoard =
ClipBoard = %ClipBoard% Problem in ConfirmDesiredPixelAtLocation - Unable to find pixel at %LocationComment%`r`n
ClipBoard = %ClipBoard% `r`n
ClipBoard = %ClipBoard% Trying to find %LocationComment% on %WindowTitle%`r`n
ClipBoard = %ClipBoard% The mouse is currently positioned on the target`r`n
ClipBoard = %ClipBoard% Search centered at (%X%, %y%) on %CurrentTitle%`r`n
ClipBoard = %ClipBoard% Search grid is (%Xmin% to %Xmax%, %Ymin% to %Ymax%)`r`n
ClipBoard = %ClipBoard% `r`n
ClipBoard = %ClipBoard% The above result is on clipboard `r`n
ClipBoard = %ClipBoard% Exiting script `r`n
MsgBox, %ClipBoard%
Exit
}
Else
{
WinGetActiveTitle, CurrentTitle
;ClipBoard =
ClipBoard = %ClipBoard% Problem in ConfirmDesiredPixelAtLocation - Invalid ErrorLevel or Flag while attemptng to find %LocationComment%`r`n
ClipBoard = %ClipBoard% `r`n
ClipBoard = %ClipBoard% ErrorLevel = |%ErrorLevel%|`r`n
ClipBoard = %ClipBoard% Flag = |%Flag%|`r`n
ClipBoard = %ClipBoard% CurrentTitle = |%CurrentTitle%|`r`n
ClipBoard = %ClipBoard% WindowTitle = |%WindowTitle%|`r`n
ClipBoard = %ClipBoard% Valid error levels are 0 & 1.`r`n
ClipBoard = %ClipBoard% `r`n
ClipBoard = %ClipBoard% The above result is on clipboard `r`n
ClipBoard = %ClipBoard% Exiting script `r`n
MsgBox, %ClipBoard%
Exit
}
}When I run it, I get the following output:X = 20.000000
Y = 67.000000
Xmin = 18.000000
Xmax = 22.000000
Ymin = 65.000000
Ymax = 69.000000
LoopTime = 5000
DesiredColor = 0xFCAB72
EndTime = 138043047
Problem in ConfirmDesiredPixelAtLocation - Invalid ErrorLevel or Flag while attemptng to find blue chimney on Home tab
ErrorLevel = |2|
Flag = |0|
CurrentTitle = |correct window title - cant display it|
WindowTitle = |correct window title - cant display it|
Valid error levels are 0 & 1.
The above result is on clipboard
Exiting script
The description of PixelSearch in the command list states:
I am not much of programmer and havent a clue how to determine the problem preventing this command from being executed. This is the only place PixelSearch appears in my script. There arent any other scripts loaded. There arent any parallel threads running that I am aware of. Some help would be appreciated. Thanks.ErrorLevel is set to 0 if the color was found in the specified region, 1 if it was not found, or 2 if there was a problem that prevented the command from conducting the search.




