I have a program that uses pixelsearch to find a color and then DLLcall("mouse_event") to that particular color until that color is in the center of the screen when navigating through a first person environment. The issue is that since pixelsearch stops at the top left of the blob, since it finds the pixel there, the top left part of the blob is placed in the center of the screen exactly. I want the center of the blob in the center of the screen. The blob is of unknown width and height at any given time. Here is the portion of the script that deals with this function - ingore the math in the If Yfound and If Xfound functions, as well as the checks for being between certain variables. Those are the checks to make sure it is close enough to the center, otherwise move less until it is close to the center. The intial variables of Xfound -1720 and yfound -720 are so that it navigates to the center, and the startTime variable is used elsewhere. This code DLLcalls the mouse to the top left as described:
Code: Select all
PixelSearch, Xfound, Yfound, 500, 25, 3000, 1400, 0x9F830C, 0, fast
If ErrorLevel = 0
{
StartTime += 1
Xfound -= 1720
Yfound -= 720
If Yfound not between -200 and 200
{
Yfound = (Yfound/10)
Xfound = 0
}
If Xfound not between -300 and 300
{
Xfound =(Xfound/10)
}
Xfound
DllCall("mouse_event", "UInt", 0x01, "UInt", Xfound, "UInt", Yfound)
}
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]