N
nyaaa
Unregistered / Unconfirmed
GUEST, unregistred user!
我想定时找出某个特定的程序并将程序界面截下来保存,用了下面的代码
procedure TForm1.Timer1Timer(Sender: TObject);
var
Bild:TBitmap;
c:Tcanvas;
r,t:TRect;
h:THandle;
hh:hwnd;
ExeFilePath:string;
begin
ExeFilePath:=ExtractFilePath(Application.ExeName);
hh:=findwindow(nil,'计算器');
if hh>0 then
SetActiveWindow(hh)
else
showmessage('not find');
c:=TCanvas.Create;
c.Handle:=GetWindowDC(GetDesktopWindow);
//获得当前活动窗口的句柄
h := GetForeGroundWindow;
Bild:=TBitmap.Create;
if h<>0 then
//结构t保存该窗口的左上角和右下角的坐标值(相对于屏幕左上角)
GetWindowRect(h,t);
try
r:=Rect(0,0,t.Right-t.Left,t.Bottom-t.Top);
Bild.Width:=t.Right-t.Left;
Bild.Height:=t.Bottom-t.Top;
Bild.Canvas.CopyRect(r,c,t);
//抓屏结果保存在与EXE相同目录下
Bild.SaveToFile(ExeFilePath+'screen.bmp');
finally
Bild.Free;
end;
end;
可是截下来的图是我编程序的截面,该怎么写,请帮忙!
谢谢!
procedure TForm1.Timer1Timer(Sender: TObject);
var
Bild:TBitmap;
c:Tcanvas;
r,t:TRect;
h:THandle;
hh:hwnd;
ExeFilePath:string;
begin
ExeFilePath:=ExtractFilePath(Application.ExeName);
hh:=findwindow(nil,'计算器');
if hh>0 then
SetActiveWindow(hh)
else
showmessage('not find');
c:=TCanvas.Create;
c.Handle:=GetWindowDC(GetDesktopWindow);
//获得当前活动窗口的句柄
h := GetForeGroundWindow;
Bild:=TBitmap.Create;
if h<>0 then
//结构t保存该窗口的左上角和右下角的坐标值(相对于屏幕左上角)
GetWindowRect(h,t);
try
r:=Rect(0,0,t.Right-t.Left,t.Bottom-t.Top);
Bild.Width:=t.Right-t.Left;
Bild.Height:=t.Bottom-t.Top;
Bild.Canvas.CopyRect(r,c,t);
//抓屏结果保存在与EXE相同目录下
Bild.SaveToFile(ExeFilePath+'screen.bmp');
finally
Bild.Free;
end;
end;
可是截下来的图是我编程序的截面,该怎么写,请帮忙!
谢谢!