mastaraymond
07-21-2007, 08:26 PM
Well since no one really cared, i will post it here:
Hello,
After i made some TPointArray functions i saw they were pretty slow. This is why i made my first plugin! I'll stop talking, here are the Functions:
Function MostCommonColorBox(x1, y1, x2, y2:integer;Window:Hwnd):integer;
Function InArray(TheNumber,l:integer;var i:integer;TheArray:TIntegerArray):Boolean;
Function BubbleTPointArray(ThePoints:TPointArray; SortX,SmallToLarge:boolean):TPointArray;
Function GetTPointArrayPeaks(ThePoints:TPointArray; Maximum:boolean): TPoint;
Procedure TPointArrayToIntegerArray(ThePoints:TPointArray;va r XArray,YArray:TIntegerArray);
Function FindCommonPointsRange(GoodPoints,BadPoints:TPointA rrayArray;Range:integer; Closest:Boolean;var ThePoint:TPoint): Boolean;
More of this one below!
For window fill in GetClientWindowHandle,
InArray returns True if the given Number is in the Array, it also returns the position of the found number in the var I and for L you need to fill in the length of the array, Length(TheArray).
I think they are pretty easy to understand :-). Please test the MostCommonColorBox at runescape: program New;
var
TempTime:Integer;
begin
TempTime:=GetSystemTime;
Writeln('');
WriteLn('The most common color of the Runescape Screen = '+inttostr(MostCommonColorBox(0,0,762, 501, GetClientWindowHandle)));
Writeln('It took us '+inttostr(GetSystemTime-TempTime)+' ms to find out!');
Writeln('');
end.
Also i need some ideas for functions i could make in a plugin :p.
Update:
Ok someone asked me today if i could help him on his Autofighter, i said yes and started thinking. A good way to make sure the beast you are looking for is, the beasts that turns out of your Colour searching! So i thought, if i make a function that checks if all the colours you are looking for is in a 'box'. I made a scar version, and found its kinda slow. So i made a Delphi function:
Function FindCommonPointsRange(GoodPoints,BadPoints:TPointA rrayArray;Range:integer; Closest:Boolean;var ThePoint:TPoint): Boolean;
ThePoints is a array of TPointArray ;). Every TPointArray must contain x's and y's of the found color. Then we got 'range'. This is basicly how big you want to make the box where you are going to check. Its created this way and made of the FIRST TPointArray!: Bla[I].x1 - Range, Bla[I].y1 - range, Bla[I].x2 + range, Bla[I].y2 + range.
Then got 'ThePoint', if the colors of the other TPointArrays are found in the box, it will create a point in the 'middle' of the found points, created this way: Round((Bla[0].x + bla[1].x div 2)) etc..
Boolean ofcourse if it IS found ;). IF YOU USE IT BE SURE THE POINTS YOU ARE LOOKING FOR ARE CLOSE TO EACHOTHER! AND MAKE SURE THE FIRST TPOINTARRAY IS KINDA THE MIDDLE :p. *cough* this is like a DTM but then different :rolleyes: *cough*
Here i made a sample script: Updated one below! + Explanation new parameters!
Update:2
Yea, another update! This time I Updated FindCommonPointsRange! I added some posibilities, you can now choose, whether to start searching from closest to furthest, or furthest to closest AND you can now put in badpoints, points which should NOT be in the range of the good points! :)
Good luck, here an updated script! I added some array check functions too, here we go:
program New;
var
ThePoint:TPoint;
TempTime:Integer;
Function FindBySameColors( GoodColors,BadColors : TIntegerArray; Range,Tol:integer;Closest:Boolean; var Point:TPoint):Boolean;
var
I,II,L,LL,LLL,LLLL:integer;
GoodClorsTemp,Good, Duplicate : TIntegerArray;
Clean : Boolean;
GoodPoints,BadPoints: TPointArrayArray;
begin;
L:= Length(GoodColors);
LL:= Length(BadColors);
GoodClorsTemp := GoodColors;
For I:= 0 to L-1 do
if not (GoodClorsTemp[I] = -1)then
begin;
Clean := true;
For II := 0 to LL-1 do
if SimilarColors(GoodClorsTemp[I],BadColors[II],TOL) then
begin;
Clean := False;
break;
end;
if clean then
For II := I+1 to L-1 do
if (GoodClorsTemp[I] = GoodClorsTemp[II]) then
begin;
inc(LLL);
SetLength(Duplicate,LLL);
Duplicate[LLL-1] := GoodClorsTemp[I];
GoodClorsTemp[II] := -1;
end;
if clean then
begin;
inc(LLLL);
SetLength(Good,LLLL);
Good[LLLL-1] := GoodClorsTemp[I];
end;
end;
L:= Length(Good);
SetLength(GoodPoints,L);
SetLength(BadPoints,LL);
LLLL:=L;
For I:= 0 to L -1 do
FindColorsSpiralTolerance(MSCX,MSCY,GoodPoints[I],Good[I],MSX1,MSY1,MSX2,MSY2,Tol);
For I:= 0 to LL-1 do
FindColorsSpiralTolerance(MSCX,MSCY,BadPoints[I],BadColors[I],MSX1,MSY1,MSX2,MSY2,Tol);
if LLL > 0 then
begin;
for I:= 0 to L-1 do
for II:= 0 to LLL-1 do
if (Good[I] = Duplicate[II]) then
begin;
inc(LLLL);
SetLength(GoodPoints,LLLL);
GoodPoints[LLLL-1] := GoodPoints[I];
end;
end;
if FindCommonPointsRange(GoodPoints,BadPoints,Range,C losest,Point) then Result := True
else
begin;
Result := False;
Point.x:= -1;
Point.y:= -1;
end;
end;
begin
TempTime:= GetSystemTime;
if (FindBySameColors([1320110,2763308,6842480,4671822],[],20,0,true,ThePoint)) then
MoveMouse(ThePoint.x,ThePoint.y);
Writeln(inttostr(GetSystemTime - TempTime));
end.
~Raymond
I made some on top functions:
Function OnTopDebugCanvas(OnTop : Boolean): Boolean;
Function SetOnTop(Handle : Integer; OnTop : Boolean ):Boolean;
Function SetOnTopTitle(Title : String; OnTop : Boolean):Boolean;
Function MoveDebugCanvas(x,y : Integer):Boolean ;
check OnTop.rar.
Hello,
After i made some TPointArray functions i saw they were pretty slow. This is why i made my first plugin! I'll stop talking, here are the Functions:
Function MostCommonColorBox(x1, y1, x2, y2:integer;Window:Hwnd):integer;
Function InArray(TheNumber,l:integer;var i:integer;TheArray:TIntegerArray):Boolean;
Function BubbleTPointArray(ThePoints:TPointArray; SortX,SmallToLarge:boolean):TPointArray;
Function GetTPointArrayPeaks(ThePoints:TPointArray; Maximum:boolean): TPoint;
Procedure TPointArrayToIntegerArray(ThePoints:TPointArray;va r XArray,YArray:TIntegerArray);
Function FindCommonPointsRange(GoodPoints,BadPoints:TPointA rrayArray;Range:integer; Closest:Boolean;var ThePoint:TPoint): Boolean;
More of this one below!
For window fill in GetClientWindowHandle,
InArray returns True if the given Number is in the Array, it also returns the position of the found number in the var I and for L you need to fill in the length of the array, Length(TheArray).
I think they are pretty easy to understand :-). Please test the MostCommonColorBox at runescape: program New;
var
TempTime:Integer;
begin
TempTime:=GetSystemTime;
Writeln('');
WriteLn('The most common color of the Runescape Screen = '+inttostr(MostCommonColorBox(0,0,762, 501, GetClientWindowHandle)));
Writeln('It took us '+inttostr(GetSystemTime-TempTime)+' ms to find out!');
Writeln('');
end.
Also i need some ideas for functions i could make in a plugin :p.
Update:
Ok someone asked me today if i could help him on his Autofighter, i said yes and started thinking. A good way to make sure the beast you are looking for is, the beasts that turns out of your Colour searching! So i thought, if i make a function that checks if all the colours you are looking for is in a 'box'. I made a scar version, and found its kinda slow. So i made a Delphi function:
Function FindCommonPointsRange(GoodPoints,BadPoints:TPointA rrayArray;Range:integer; Closest:Boolean;var ThePoint:TPoint): Boolean;
ThePoints is a array of TPointArray ;). Every TPointArray must contain x's and y's of the found color. Then we got 'range'. This is basicly how big you want to make the box where you are going to check. Its created this way and made of the FIRST TPointArray!: Bla[I].x1 - Range, Bla[I].y1 - range, Bla[I].x2 + range, Bla[I].y2 + range.
Then got 'ThePoint', if the colors of the other TPointArrays are found in the box, it will create a point in the 'middle' of the found points, created this way: Round((Bla[0].x + bla[1].x div 2)) etc..
Boolean ofcourse if it IS found ;). IF YOU USE IT BE SURE THE POINTS YOU ARE LOOKING FOR ARE CLOSE TO EACHOTHER! AND MAKE SURE THE FIRST TPOINTARRAY IS KINDA THE MIDDLE :p. *cough* this is like a DTM but then different :rolleyes: *cough*
Here i made a sample script: Updated one below! + Explanation new parameters!
Update:2
Yea, another update! This time I Updated FindCommonPointsRange! I added some posibilities, you can now choose, whether to start searching from closest to furthest, or furthest to closest AND you can now put in badpoints, points which should NOT be in the range of the good points! :)
Good luck, here an updated script! I added some array check functions too, here we go:
program New;
var
ThePoint:TPoint;
TempTime:Integer;
Function FindBySameColors( GoodColors,BadColors : TIntegerArray; Range,Tol:integer;Closest:Boolean; var Point:TPoint):Boolean;
var
I,II,L,LL,LLL,LLLL:integer;
GoodClorsTemp,Good, Duplicate : TIntegerArray;
Clean : Boolean;
GoodPoints,BadPoints: TPointArrayArray;
begin;
L:= Length(GoodColors);
LL:= Length(BadColors);
GoodClorsTemp := GoodColors;
For I:= 0 to L-1 do
if not (GoodClorsTemp[I] = -1)then
begin;
Clean := true;
For II := 0 to LL-1 do
if SimilarColors(GoodClorsTemp[I],BadColors[II],TOL) then
begin;
Clean := False;
break;
end;
if clean then
For II := I+1 to L-1 do
if (GoodClorsTemp[I] = GoodClorsTemp[II]) then
begin;
inc(LLL);
SetLength(Duplicate,LLL);
Duplicate[LLL-1] := GoodClorsTemp[I];
GoodClorsTemp[II] := -1;
end;
if clean then
begin;
inc(LLLL);
SetLength(Good,LLLL);
Good[LLLL-1] := GoodClorsTemp[I];
end;
end;
L:= Length(Good);
SetLength(GoodPoints,L);
SetLength(BadPoints,LL);
LLLL:=L;
For I:= 0 to L -1 do
FindColorsSpiralTolerance(MSCX,MSCY,GoodPoints[I],Good[I],MSX1,MSY1,MSX2,MSY2,Tol);
For I:= 0 to LL-1 do
FindColorsSpiralTolerance(MSCX,MSCY,BadPoints[I],BadColors[I],MSX1,MSY1,MSX2,MSY2,Tol);
if LLL > 0 then
begin;
for I:= 0 to L-1 do
for II:= 0 to LLL-1 do
if (Good[I] = Duplicate[II]) then
begin;
inc(LLLL);
SetLength(GoodPoints,LLLL);
GoodPoints[LLLL-1] := GoodPoints[I];
end;
end;
if FindCommonPointsRange(GoodPoints,BadPoints,Range,C losest,Point) then Result := True
else
begin;
Result := False;
Point.x:= -1;
Point.y:= -1;
end;
end;
begin
TempTime:= GetSystemTime;
if (FindBySameColors([1320110,2763308,6842480,4671822],[],20,0,true,ThePoint)) then
MoveMouse(ThePoint.x,ThePoint.y);
Writeln(inttostr(GetSystemTime - TempTime));
end.
~Raymond
I made some on top functions:
Function OnTopDebugCanvas(OnTop : Boolean): Boolean;
Function SetOnTop(Handle : Integer; OnTop : Boolean ):Boolean;
Function SetOnTopTitle(Title : String; OnTop : Boolean):Boolean;
Function MoveDebugCanvas(x,y : Integer):Boolean ;
check OnTop.rar.