Autor Beitrag
pk910
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 74

Win VISTA, Win 98, Win XP, Linux
Delphi 5.0
BeitragVerfasst: Mi 10.10.07 12:12 
Wie kann ich einen Screenshot nur von einem anderem Programm erstellen?

ich habs mit folgendem code versucht:
ausblenden Delphi-Quelltext
1:
Image1.Canvas.Handle:=GetWindowDC(FindWindow(nil, 'Windows Task-Manager'));					


'Windows Task-Manager' ist hier nur ein Beispiel

bei dem code wird garnichts angezeigt...


screenshot vom ganzen desktop geht auch nicht,
da das zu "fotografierende" Programm standartmäßig
minimiert ist...

und erst alles minimieren, das programm maximieren und screen machen
passt auch nicht ganz, da ich am PC weiter arbeiten will ^^


was für möglichkeiten gibts noch?

mfg. philipp
Jann1k
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 866
Erhaltene Danke: 43

Win 7
TurboDelphi, Visual Studio 2010
BeitragVerfasst: Mi 10.10.07 17:41 
verstehe ich das richtig? du willst einen screenshot von einem programm machen, das minimiert ist? würde mich wundern wenn das geht
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Mi 10.10.07 17:44 
Schätze, etwas das nicht gezeichnet ist, kann nicht kopiert werden (in die Zwischenablage für einen Screenshot)

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Wolle92
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Mi 10.10.07 18:03 
Nein, er will, dass ein minimiertes Programm einen Screenshot vom Bildschirm/von einem anderen Programm macht...
Also nicht das Programm maximieren (wär ja auch doof, dann sieht man ja das andere Programm nicht)
Aber ne Lösung habe ich nicht... Wollte nur die Unklarheit beseitigen...
bflegel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 193
Erhaltene Danke: 1

Win XP, Win 7, BS2000
D5
BeitragVerfasst: Mi 10.10.07 18:13 
Hallo,

ich habe mal ein Programm geschrieben dass Snapshots von wahlweise einem aktiven Fenster oder vom ganzen Bildschirm macht (mit Mehrfach-Snapshots, Zeitverzögerung ...). Die eigentliche Routine des Snapshots ist:

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:
procedure TForm1.Screenshot;

var
pic : TBitMap;
c : TCanvas;
r, t : TRect;
h : THandle;
dateiname : string;
akt_datum, akt_uhrzeit : string;
DesktopDC: HDC;

begin
  if abbrechen then
    begin
      abbrechen := false;
      timer_durchlauf := 0;
    end
  else
    begin
          akt_datum := DateTimeToStr(date());
          akt_datum := Copy(akt_datum,1,2) +        //Datumsformat ttmmjj
              Copy(akt_datum,4,2) +
              Copy(akt_datum,9,2);
          akt_uhrzeit := DateTimeToStr(time());
          akt_uhrzeit := Copy(akt_uhrzeit,12,2) +   //Uhrzeitformat hhmmss
              Copy(akt_uhrzeit,15,2) +
              Copy(akt_uhrzeit,18,2);
          dateiname := Speicherort_bilder + '\Snapshot_' +
              akt_datum + '_' + akt_uhrzeit + '.bmp';
      if Combobox4.ItemIndex = 0 then       //Aktives Fenster speichern
        begin
          pic := TBitMap.Create;
          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);
            pic.Width := t.Right-t.left;
            pic.Height := t.Bottom-t.Top;
            pic.Canvas.CopyRect(r, c, t);
          finally
            ReleaseDC(0, c.handle);
            c.Free;
          end;
          pic.SaveToFile(dateiname);
          pic.free;
        end
      else                                  //Gesamten Bildschirm speichern
        begin
          pic := TBitMap.Create;
          DesktopDC := CreateDC('DISPLAY', nil, nil, nil);
            try
              pic.PixelFormat := pfDevice;
              pic.Width := Screen.Width;
              pic.Height := Screen.Height;
              BitBlt(pic.Canvas.Handle, 0, 0, Screen.Width, Screen.Height, DesktopDC, 0, 0, SRCCOPY);
            finally
              DeleteDC(DesktopDC);
              pic.SaveToFile(dateiname);
              pic.free;
            end;
        end;
    end;
  Application.ProcessMessages;
end;


Falls Interesse besteht, kann ich es mal samt Source zur Verfügung stellen (wobei ich sagen muss, dass ich mir die eigentlichen Routinen auch aus diesem und anderen Foren zusammengesucht und an meine Bedürfnisse angepasst habe.

bye bflegel

_________________
I know all the jokes about my name
pk910 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 74

Win VISTA, Win 98, Win XP, Linux
Delphi 5.0
BeitragVerfasst: Do 11.10.07 21:33 
user profile iconbflegel hat folgendes geschrieben:
Hallo,

ich habe mal ein Programm geschrieben dass Snapshots von wahlweise einem aktiven Fenster oder vom ganzen Bildschirm macht (mit Mehrfach-Snapshots, Zeitverzögerung ...). Die eigentliche Routine des Snapshots ist:

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:
procedure TForm1.Screenshot;

var
pic : TBitMap;
c : TCanvas;
r, t : TRect;
h : THandle;
dateiname : string;
akt_datum, akt_uhrzeit : string;
DesktopDC: HDC;

begin
  if abbrechen then
    begin
      abbrechen := false;
      timer_durchlauf := 0;
    end
  else
    begin
          akt_datum := DateTimeToStr(date());
          akt_datum := Copy(akt_datum,1,2) +        //Datumsformat ttmmjj
              Copy(akt_datum,4,2) +
              Copy(akt_datum,9,2);
          akt_uhrzeit := DateTimeToStr(time());
          akt_uhrzeit := Copy(akt_uhrzeit,12,2) +   //Uhrzeitformat hhmmss
              Copy(akt_uhrzeit,15,2) +
              Copy(akt_uhrzeit,18,2);
          dateiname := Speicherort_bilder + '\Snapshot_' +
              akt_datum + '_' + akt_uhrzeit + '.bmp';
      if Combobox4.ItemIndex = 0 then       //Aktives Fenster speichern
        begin
          pic := TBitMap.Create;
          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);
            pic.Width := t.Right-t.left;
            pic.Height := t.Bottom-t.Top;
            pic.Canvas.CopyRect(r, c, t);
          finally
            ReleaseDC(0, c.handle);
            c.Free;
          end;
          pic.SaveToFile(dateiname);
          pic.free;
        end
      else                                  //Gesamten Bildschirm speichern
        begin
          pic := TBitMap.Create;
          DesktopDC := CreateDC('DISPLAY', nil, nil, nil);
            try
              pic.PixelFormat := pfDevice;
              pic.Width := Screen.Width;
              pic.Height := Screen.Height;
              BitBlt(pic.Canvas.Handle, 0, 0, Screen.Width, Screen.Height, DesktopDC, 0, 0, SRCCOPY);
            finally
              DeleteDC(DesktopDC);
              pic.SaveToFile(dateiname);
              pic.free;
            end;
        end;
    end;
  Application.ProcessMessages;
end;


Falls Interesse besteht, kann ich es mal samt Source zur Verfügung stellen (wobei ich sagen muss, dass ich mir die eigentlichen Routinen auch aus diesem und anderen Foren zusammengesucht und an meine Bedürfnisse angepasst habe.

bye bflegel


danke =))

ich werde das progrmm noch etwas verändern, sodass ich ein fenster bestimmen kann...
mfg. philipp