如何在程式運行中自動執行 Alt+PrintScreen 並且存檔 |
答題得分者是:pceyes
|
lovemari
中階會員 發表:134 回覆:224 積分:76 註冊:2005-08-18 發送簡訊給我 |
DEAR 各位大大
你們好 小弟想在程式執行特定一段時間之後 會自動 Alt PrintScreen 的方式擷取程式畫面 並且自動存檔在硬碟裡面 該如何去做呢 THANKS
------
Program : Delphi 7 DataBase : Oracle 9i Client : ClientDataSet |
st33chen
尊榮會員 發表:15 回覆:591 積分:1201 註冊:2005-09-30 發送簡訊給我 |
您好,
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 發送簡訊給我 |
[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 發送簡訊給我 |
|
pceyes
尊榮會員 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
[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 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |