線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2726
推到 Plurk!
推到 Facebook!

如何在程式運行中自動執行 Alt+PrintScreen 並且存檔

答題得分者是:pceyes
lovemari
中階會員


發表:134
回覆:224
積分:76
註冊:2005-08-18

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-11-27 16:41:44 IP:122.116.xxx.xxx 訂閱
DEAR 各位大大 
你們好

小弟想在程式執行特定一段時間之後
會自動 Alt PrintScreen 的方式擷取程式畫面
並且自動存檔在硬碟裡面
該如何去做呢

THANKS
------
Program : Delphi 7
DataBase : Oracle 9i
Client : ClientDataSet
編輯記錄
lovemari 重新編輯於 2008-11-27 16:42:39, 註解 無‧
lovemari 重新編輯於 2008-11-27 18:25:58, 註解 無‧
lovemari 重新編輯於 2008-11-27 18:33:35, 註解 無‧
lovemari 重新編輯於 2008-11-27 18:34:04, 註解 無‧
st33chen
尊榮會員


發表:15
回覆:591
積分:1201
註冊:2005-09-30

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-11-28 08:57:13 IP:122.116.xxx.xxx 未訂閱
您好,

1. 一段時間用 TIMER 您會的.
2. CAPTURE SCREEN 可參考
http://delphi.about.com/od/delphitips2008/qt/print_window.htm
或 SEARCH 一下本站, 應該很多資料.
------
IS IT WHAT IT IS
我是 李慕白 請倒著唸.
又想把老話拿出來說, 請用台語發音 : 專家專家全是ROBOT CAR (滷肉腳啦);
都已接手這麼久了, 績效還是那麼爛, 講話還那麼大聲.
編輯記錄
st33chen 重新編輯於 2008-11-28 09:03:14, 註解 無‧
pceyes
尊榮會員


發表:70
回覆:657
積分:1140
註冊:2003-03-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2008-11-28 10:13:29 IP:122.118.xxx.xxx 訂閱

[code delphi]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;

type
TForm1 = class(TForm)
Image1: TImage;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation
{$R *.dfm}
procedure ScreenShot(DestBitmap : TBitmap) ;
var
DC: HDC;
begin
DC := GetDC (GetDesktopWindow) ;
try
DestBitmap.Width := GetDeviceCaps (DC, HORZRES) ;
DestBitmap.Height := GetDeviceCaps (DC, VERTRES) ;
BitBlt(DestBitmap.Canvas.Handle,
0,
0,
DestBitmap.Width,
DestBitmap.Height,
DC,
0,
0,
SRCCOPY) ;
finally
ReleaseDC (GetDesktopWindow, DC) ;
end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
bmp: TBitmap;
begin
bmp := TBitmap.Create;
ScreenShot(bmp);
image1.Picture.Bitmap.Assign(bmp); // 顯示用
bmp.SaveToFile('c:\screen.bmp'); // 存檔用
bmp.Free;

end;
end.

[/code]
------
努力會更接近成功
lovemari
中階會員


發表:134
回覆:224
積分:76
註冊:2005-08-18

發送簡訊給我
#4 引用回覆 回覆 發表時間:2008-11-28 16:05:35 IP:122.116.xxx.xxx 訂閱
謝謝 pceyes 大大

你提供的程式小弟可執行 可存檔了

想在請教各小地方

就是該擷取出來是全影幕

小弟只想要當前運行的程式畫面而已

功能= Alt PrientScreen 即可

我是不是該把GetDesktopWindow 改成什麼呢??
------
Program : Delphi 7
DataBase : Oracle 9i
Client : ClientDataSet
pceyes
尊榮會員


發表:70
回覆:657
積分:1140
註冊:2003-03-13

發送簡訊給我
#5 引用回覆 回覆 發表時間:2008-11-28 17:45:32 IP:220.141.xxx.xxx 訂閱

[code delphi]

procedure ScreenShotActiveWindow(Bild: TBitMap);
var
c: TCanvas;
r, t: TRect;
h: THandle;
begin
c := TCanvas.Create;
c.Handle := GetWindowDC(GetDesktopWindow);
h := GetForeGroundWindow;
if h <> 0 then
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);
finally
ReleaseDC(0, c.Handle);
c.Free;
end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Image1.Picture := nil;
ScreenShotActiveWindow(Image1.Picture.BitMap);
image1.Picture.SaveToFile('c:\123.bmp');
end;

[/code]
------
努力會更接近成功
lovemari
中階會員


發表:134
回覆:224
積分:76
註冊:2005-08-18

發送簡訊給我
#6 引用回覆 回覆 發表時間:2008-11-28 18:37:31 IP:122.116.xxx.xxx 訂閱
感謝 pceyes
------
Program : Delphi 7
DataBase : Oracle 9i
Client : ClientDataSet
系統時間:2024-05-02 20:29:46
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!