PrintWindow函数截图 全部分数都给你们,只求帮忙
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;type TForm1 = class(TForm) Timer1: TTimer; Button1: TButton; procedure Timer1Timer(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1; function EnumWindowsProc(AhWnd:LongInt;AForm:TForm1):boolean;stdcall; Function PrintWindow(SourceWindow: hwnd; Destination: hdc; nFlags: cardinal): bool; stdcall; external 'user32.dll' name 'PrintWindow';implementation{$R *.dfm}function EnumWindowsProc(AhWnd:LongInt;AForm:TForm1):boolean;var lpszWindowText:array[0..254] of char; Bitmap: TBitmap; rec : TRect; //x, y : Integer;begin GetWindowText(AhWnd,lpszWindowText,254); if pos('百度搜索',StrPas(lpszWindowText))>0 then begin GetWindowRect(AhWnd, rec); //获取到窗口的矩形 Bitmap := TBitmap.Create; try Bitmap.Width := rec.Right - rec.Left; Bitmap.Height := rec.Bottom - rec.Top; Bitmap.PixelFormat := pf24bit; PrintWindow(AhWnd, Bitmap.Canvas.Handle, 0); Bitmap.SaveToFile(FormatDatetime('yyyymmddhhnnss', Now())+'led.bmp'); finally Bitmap.Free; end; end; Result:=True;end;procedure TForm1.Timer1Timer(Sender: TObject);beginEnumWindows(@EnumWindowsProc,LongInt(self));end;procedure TForm1.Button1Click(Sender: TObject);beginTimer1Timer(nil);end;end.