Solved

Taking Screenshots for Processing in Delphi.

Posted on 2004-04-05
2
309 Views
Last Modified: 2010-04-05
I want to be able to take screenshots of my desktop and compare then pixel by pixel or otherwise to another screenshot in memory. The purpose of this is to isolate an object from a known background and return a coordinate, preferably in real time.

Thanks alot for any help you can provide.

Tom.
0
Comment
Question by:nop-90
  • 2
2 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10761193
var
 screenShot : TBitmap;
 dc : HDC;
begin
 screenShot := TBitmap.create;
 with screenShot do
 begin
  pixelFormat := pf24bit;
  width := screen.wdith;
  height := screen.height;
 end;
 dc := getDC(getDeskTopWindow);
 biblt(
  screenShot.canvas.handle,
  0,0,screen.width,screen.height,
  dc,
  0,0,
  SRCCOPY);
 releaseDC(getDeskTopWindow,dc);
end;

Shane
0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 125 total points
ID: 10761218
Also, here is a solution from another expert (DragonSlayer)

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20175477.html?query=screenshot&searchType=topic


Accepted Answer from DragonSlayer
Date: 08/29/2001 12:40AM PDT
 Accepted Answer  


didn't try to compile it, but I think it will work:

uses
  Windows, clipbrd;

procedure CaptureScreen(WholeDesktop: Boolean);
var
  Desktop: HWND;
  DesktopDC: HDC;
  FWidth, FHeight, FLeft, FTop: Integer;
  AImage: TBitmap;
  WindowRect: TRect;
  AFormat: Word;
  AData, APalette : THandle;
begin
  Desktop := GetDesktopWindow;

  AImage := TBitmap.Create;
  if WholeDesktop then
  begin
    FWidth := Screen.Width;
    FHeight := Screen.Height;
    FLeft := 1;
    FTop := 1;
  end else
  begin
    GetWindowRect(GetTopWindow(0), WindowRect);
    FWidth := WindowRect.Right - WindowRect.Left;
    FHeight := WindowRect.Bottom - WindowRect.Top;
    FLeft := WindowRect.Left;
    FTop := WindowRect.Top;
  end;

  DesktopDC := GetWindowDC(Desktop);
  try
    AImage.Width := FWidth;
    AImage.Height := FHeight;
    BitBlt(AImage.Canvas.Handle, 0, 0, FWidth, FHeight,
      DesktopDC, FLeft, FTop, SRCCOPY);
    AImage.SaveToClipBoardFormat(AFormat, AData, APalette);
    ClipBoard.SetAsHandle(AFormat, AData);
  finally
    ReleaseDC(Desktop, DesktopDC);
    AImage.Free;
  end;
end;

Shane
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 86
error 1.1 400 Bad request idhttp delphi 18 152
Strange behavior when a form is closed 6 61
tvirtualstringtree freeze when load too manny images 10 73
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question