Autor Beitrag
ultra2k
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

XP x64
D7 Enterprise
BeitragVerfasst: Mi 29.03.06 01:03 
Hallo zusammen,

wie der Titel schon sagt, hätte ich gerne gewusst, wie es zu bewerkstelligen ist Screenshots von versteckten, bzw, nur teilweise sichtbaren Fenstern zu machen. Da beim Programmieren ja grundsätzlich erstmal alles möglich ist, und ich bereits Programme gesehen habe, die das können, dacht ich ihr könnt mir bestimmt sagen, wie das geht :P.

Bsp:

Visual Tooltip
SmallWindows

Vielen Dank im vorraus

_________________
...wenn NULL besonders groß ist, isses schon fast wie ein bisschen EINS!
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 29.03.06 06:03 
Ich hab das selber zwar noch nicht ausprobiert, aber rein theoretisch sollte es anhand eines Tricks gehen:

Man erzeuge per WinAPI ein neues DC in der größe des Fensters
Setze das benötigte Pixelformat
Dupliziere das Handle für den Fremdprozess
Sende eine WM_PAINT-Botschaft an den Fremdprozess
Erfreue sich am Inhalt des DCs
Gebe alle Ressourcen wieder frei

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
ultra2k Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

XP x64
D7 Enterprise
BeitragVerfasst: Mi 29.03.06 11:37 
hmm... das klingt echt gut :D
sobald ich richtig wach bin, probier ichs ma :P

// EDIT: Ja, nüü... also irgendwie wills net so, wie ich will (was zu erwarten war ^^). Hättest du unter Umständen mal nen Code-Schnipsel für mich :wink:

_________________
...wenn NULL besonders groß ist, isses schon fast wie ein bisschen EINS!
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 29.03.06 13:25 
Leider ich; wie ich geschrieben hab: Nur rein von den theoretischen Grundlagen laut MSDN ausgegangen).

Poste kurz deinen; vielleicht seh ich ja, was er da nicht will.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
ultra2k Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

XP x64
D7 Enterprise
BeitragVerfasst: Mi 29.03.06 13:36 
Ehrlich gesagt, hab ich noch nicht oft sowas in die Richtung gemacht...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TMainForm.CaptureButtonClick(Sender: TObject);
var
  src:    hdc;
  window: HWnd;
  bmp:    TBitmap;
begin
  window := FindWindow('TForm', 'TeamSpeak 2');
  src := GetWindowDC(window);

  bmp := TBitmap.Create;
  bmp.Width  := 1280;
  bmp.Height := 1024;
  bmp.Handle := src;
  SendMessage(window, WM_PAINT, 0, 0);
  Image1.Picture.Bitmap := bmp;
  ReleaseDC(window, src);
  bmp.free;
end;

nich haun, wenns komplett falsch is :wink:

_________________
...wenn NULL besonders groß ist, isses schon fast wie ein bisschen EINS!
Vera
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 82

WinXP Home
Delphi 2005 Personal
BeitragVerfasst: Mi 29.03.06 15:08 
Von SmallWindows existieren die Sourcecodes: sourceforge.net/proj....php?group_id=102793

Schau doch mal wie die es gemacht haben.
ultra2k Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

XP x64
D7 Enterprise
BeitragVerfasst: Mi 29.03.06 17:32 
Joa, das hab ich so ziemlich als erstes gemacht, aber ich hab kein bisschen verstanden, weils wohl Visual C++ is oder so :? das einzige was ich kann isn bissel C, aber eigentlich kaum...

Kan mir nich jemand nen Code-Fetzen "credenzen"? :P

_________________
...wenn NULL besonders groß ist, isses schon fast wie ein bisschen EINS!
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 29.03.06 18:37 
Wenn ich mich beim Übersetzen nicht total vertan hab, sollte es so hier gehen:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
Procedure TForm1.Button1Click(Sender: TObject);

    Procedure grad(Wnd: HWND);
    Var
        Rect: Windows.TRect;
        DC, bitmapDC, windowDC: HDC;
        W, H: Integer;
        BI: BITMAPINFO;
        bitmap: HBITMAP;
        bmi: Windows.bitmap;
        colorbytes: Integer;
        ColorDepth: Integer;

        bitmapData: Pointer;
        BMP: TBitmap;

        bw: Integer;
    Begin
        SendMessage(Wnd, WM_PAINT, 0, 0);

        GetWindowRect(Wnd, Rect);

        DC := GetDC(GetDesktopWindow());
        Try
            ColorDepth := GetDeviceCaps(DC, BitsPixel);
        Finally
            ReleaseDC(GetDesktopWindow(), DC);
        End;

        W := Rect.Right - Rect.Left;
        H := Rect.Bottom - Rect.Top;

        If (ColorDepth <> 16) And (ColorDepth <> 32) Then
        Begin
            DC := GetDC(GetDesktopWindow());
            Try
                bitmap := CreateCompatibleBitmap(DC, W, H);
            Finally
                ReleaseDC(GetDesktopWindow(), DC);
            End;
        End
        Else
        Begin

            bitmapDC := CreateCompatibleDC(0);
            Try

                BI.bmiHeader.biSize := SizeOf(BITMAPINFOHEADER);
                BI.bmiHeader.biWidth := W;
                BI.bmiHeader.biHeight := H;
                BI.bmiHeader.biPlanes := 1;
                BI.bmiHeader.biBitCount := ColorDepth;
                BI.bmiHeader.biCompression := BI_RGB;
                BI.bmiHeader.biSizeImage := W * H * ColorDepth Div 8;
                BI.bmiHeader.biXPelsPerMeter := 100;
                BI.bmiHeader.biYPelsPerMeter := 100;
                BI.bmiHeader.biClrUsed := 0;
                BI.bmiHeader.biClrImportant := 0;

                bitmap := CreateDIBSection(bitmapDC, BI, DIB_RGB_COLORS, bitmapData, 0, 0);
                If bitmap = NULL Then
                Begin
                    // Alternative way.
                          // Error!?
                    Exit;
                End;

                GetObject(bitmap, SizeOf(bmi), @bmi);
                colorbytes := ColorDepth Div 8;
                bw := bmi.bmWidthBytes Div colorbytes;

            Finally
                DeleteDC(bitmapDC);
            End;
        End;

        bitmapDC := CreateCompatibleDC(0);
        Try
            SelectObject(bitmapDC, bitmap);
            windowDC := GetWindowDC(Wnd);
            Try
                BitBlt(bitmapDC, 0, 0, W, H, windowDC, 0, 0, SRCCOPY);
            Finally
                ReleaseDC(Wnd, windowDC);
            End;

        Finally
            DeleteDC(bitmapDC);
        End;

        BMP := TBitmap.Create;
        Try
            BMP.ReleaseHandle;
            BMP.ReleaseMaskHandle;
            BMP.ReleasePalette;
            BMP.Handle := bitmap;
            BMP.SaveToFile('C:\test.bmp');
        Finally
            BMP.Free;
        End;
    End;

Begin
    grad(Handle);
End;


Ist die 1:1-Übersetzung der image.cpp des besagten Projekts ... Lokale Tests schenen erfolgreich ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
ultra2k Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

XP x64
D7 Enterprise
BeitragVerfasst: So 02.04.06 16:44 
Ja Funktionieren tuts, aber nicht wenn das fenster verdeckt ist oder so, also praktisch wie ein normaler Screenshot :cry:

_________________
...wenn NULL besonders groß ist, isses schon fast wie ein bisschen EINS!