Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Delphi] GetPixel Help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
iNext
Expert Cheater
Reputation: 0

Joined: 06 Aug 2007
Posts: 138

PostPosted: Sun Aug 24, 2008 3:42 pm    Post subject: [Delphi] GetPixel Help Reply with quote

I know I've already asked something like this not too long ago but I guess I don't really understand how to use the GetPixel Function.

Here's what I'm trying to do and if someone could maybe tell me what to use or something that would be awesome.

I'm searching a .swf game's screen in 6 separate points [each one is 1 pixel] (they are to be hard coded). Each point is then scanned for its color value and if the color of that pixel is above a certain amount then a key press is simulated and the process is then repeated. I also want all of these pixels to be scanned at the same time so that if the color at 2 or more places change then 2 or more key presses will be simulated.

I understand most what should be going on in the Delphi code, I just don't know how to set it up properly. If someone could point me in the right direction, give me a sample code, or give me a link to a tutorial, or just any information at all that would be awesome.
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Sun Aug 24, 2008 5:43 pm    Post subject: Reply with quote

Something like this?
Code:

function LookForColors;
var
  c: TCanvas;
 col:TColor;
 red,blue,green:integer;
begin
  c := TCanvas.Create;
  try
    c.Handle := GetWindowDC(GetDesktopWindow);
    col := GetPixel(c.Handle, X, Y);  //MAKE THESE THE X+Y YOU WANT
    red := GetRValue(col);
    blue := GetBValue(col);
    green:= GetGValue(col);
    if red = 255 and blue = 255 and green = 255 then
            //SENDKEY HERE
  finally
    c.Free;
  end;
end;


You could check col against a solid value instead of red/green/blue individually, but its up to you. Just have fun from there.

*Instead of using the Desktop's handle, get the handle of the SWF window.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sun Aug 24, 2008 6:01 pm    Post subject: Reply with quote

Why needlessly complicate it?

Code:
void Boners(COLORREF color){
   if(GetPixel(hdc, 0, 0) == color){
      MessageBeep(MB_OK);
   }Sleep(10);
}


Just feed it an RGB macro.

Surely you can figure out the window size and how to loop through it on your own.
Back to top
View user's profile Send private message
iNext
Expert Cheater
Reputation: 0

Joined: 06 Aug 2007
Posts: 138

PostPosted: Sun Aug 24, 2008 6:05 pm    Post subject: Reply with quote

Thanks. I'm pretty sure I can take it from here now. Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites