 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
compactwater I post too much
Reputation: 8
Joined: 02 Aug 2006 Posts: 3923
|
Posted: Thu Jun 21, 2007 12:46 am Post subject: [TUT-Delphi] BitBlt/Print Screen/GetPixel! (1/5 easy) |
|
|
I got bored because of the server check + website maintenance, so I'm writing this to (maybe) enlighten someone.
I've taken the agonizing 5 minutes to write this, so I hope you like it.
I rated this 1/5, because it's just so easy. Theres really nothing, at all, what-so-ever, that you would have to know about Pascal to make this work. You can even read it, like a book, and understand what's going on, and what it's doing.
BitBlt!
Now then, first off, add this anywhere under implementation:
Note: This isn't required, it just makes things alot easier to read...
| Code: | function ShortBitBlt: TBitmap;
var
Desktop: HDC;
begin
Result := TBitmap.Create;
Desktop := GetDC(0);
try
try
Result.PixelFormat := pf32bit;
Result.Width := Screen.Width;
Result.Height := Screen.Height;
BitBlt(Result.Canvas.Handle, 0, 0, Result.Width, Result.Height, Desktop, 0, 0, SRCCOPY);
Result.Modified := True;
finally
ReleaseDC(0, Desktop);
end;
except
Result.Free;
Result := nil;
end;
end; |
Now, make a button, and an image. Make the image whatever size, as long as you can see it.
Doubleclick on the button, it should take you to "procedure TForm1.Button1Click(Sender: TObject);"
After "Begin" write this:
| Code: | | Image1.Picture.Bitmap:=ShortBitBlt; |
(See, much easier to read!)
That will use BitBlt and get the screen, then put it on "Image1".
Print Screen!
There are two ways you can do this, emulating the "Print Screen" button, then pasting it into an image, or using this simple code, that won't require anything extra for a "protected" window.
| Code: | procedure ScreenShot(Bild: TBitMap);
var
c: TCanvas;
r: TRect;
begin
c := TCanvas.Create;
c.Handle := GetWindowDC(GetDesktopWindow);
try
r := Rect(0, 0, Screen.Width, Screen.Height);
Bild.Width := Screen.Width;
Bild.Height := Screen.Height;
Bild.Canvas.CopyRect(r, c, r);
finally
ReleaseDC(0, c.Handle);
c.Free;
end;
end; |
Add that anywhere under implementation.
Now, make a button, doubleclick on it, and write this:
| Code: | | ScreenShot(Image1.Picture.BitMap); |
Very simple, right?
GetPixel!
(This will only work on non-protected processes)
Add a button, doubleclick on it, and add this:
| Code: | var
MousePos: TPoint;
ScreenDC: HDC;
begin
GetCursorPos(MousePos);
ScreenDC:=GetDC(0);
Shape1.Brush.Color:=GetPixel(ScreenDC, MousePos.X, MousePos.Y);
ReleaseDC(0, ScreenDC); |
Make sure you overwrite it from the old "begin"!
Bonus!
Getting colours from pixels, it's easier than you think!
| Code: | GetRValue(image1.Picture.Bitmap.Canvas.Pixels[MousePos.X,MousePos.Y]);
GetGValue(image1.Picture.Bitmap.Canvas.Pixels[MousePos.X,MousePos.Y]);
GetBValue(image1.Picture.Bitmap.Canvas.Pixels[MousePos.X,MousePos.Y]); |
That'll snatch the colour from your mouse (Translated onto "Image1")
|
|
| Back to top |
|
 |
Maverick Master Cheater
Reputation: 0
Joined: 24 Dec 2006 Posts: 451
|
Posted: Thu Jun 21, 2007 1:59 am Post subject: |
|
|
| Upload Delphi please? x.x
|
|
| Back to top |
|
 |
Icos Grandmaster Cheater
Reputation: 0
Joined: 12 May 2007 Posts: 524
|
Posted: Thu Jun 21, 2007 2:08 am Post subject: |
|
|
Why do people rarely use C/C++? *cries*
Anyway it looks neat. Nice job.
|
|
| Back to top |
|
 |
ravicus Master Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 464
|
|
| Back to top |
|
 |
compactwater I post too much
Reputation: 8
Joined: 02 Aug 2006 Posts: 3923
|
Posted: Thu Jun 21, 2007 12:40 pm Post subject: |
|
|
| Icos wrote: | Why do people rarely use C/C++? *cries*
Anyway it looks neat. Nice job. |
Thanks.
If anyone has any suggestions... Just post or PM me!
|
|
| Back to top |
|
 |
Simsgy Grandmaster Cheater
Reputation: 0
Joined: 07 May 2007 Posts: 581 Location: My new avatar <3
|
Posted: Sun Jun 24, 2007 4:38 am Post subject: |
|
|
Nice work, I will use it for the project I am working at.
P.S, GetPixel! is working on MapleStory?
_________________
|
|
| Back to top |
|
 |
compactwater I post too much
Reputation: 8
Joined: 02 Aug 2006 Posts: 3923
|
Posted: Sun Jun 24, 2007 5:05 am Post subject: |
|
|
| Actually, GetPixel is the only method that doesn't work. I was surprised that BitBlt worked, but knew that Print Screen would work.
|
|
| Back to top |
|
 |
Simsgy Grandmaster Cheater
Reputation: 0
Joined: 07 May 2007 Posts: 581 Location: My new avatar <3
|
Posted: Sun Jun 24, 2007 5:37 am Post subject: |
|
|
Alright, what is BitBlt doing?
P.S, is the bonus working on MapleStory?
_________________
|
|
| Back to top |
|
 |
|
|
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
|
|