Autor |
Beitrag |
Christian V.
      
Beiträge: 311
Win Xp Prof
Turbo Delphi 2005
|
Verfasst: So 21.08.05 12:35
Hallo,
Ich schreibe gerade ein PRogramm, das auf Tastendruck das aktive Fenster versteckt.
Jedoch funktioniert das nicht bei allen Anwendungen. Z.B. bei Spielen funktioniert das nicht. Wie kann ich das vermeiden, das Spiele sich selbst wieder sichtbar machen?
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:
| unit Sh;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,shellapi;
type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); protected procedure hotkey(var msg:Tmessage); message WM_HOTKEY; private id:integer; public end;
var Form1: TForm1; h2:hwnd; o,x:integer; implementation uses gamma;
{$R *.dfm} function hideactive():boolean; var rampe: TGammaRamp; hnd: HWND;
begin if (isWindowVisible(h2)) or (h2<>0) then else begin hnd := GetForegroundWindow;
ShowWindow(hnd,SW_HIDE); h2:=hnd;
end; end; function showactive():boolean; var hnd: HWND; rampe: TGammaRamp; begin
if h2<>0 then begin ShowWindow(h2,SW_SHOW); rampe := Tgammaramp.Create; rampe.SetBrightness(0,128); rampe.FreeLib; h2:=0; end; end;
procedure TForm1.hotkey(var msg:TMessage); begin case msg.wparam of 1 : hideactive(); 2 : showactive(); 3 : Form1.Close; end; end; procedure TForm1.FormCreate(Sender: TObject); begin MessageDlg(Format('Screen Width = %d' + #13#10 + 'Screen Height = %d', [Screen.Width, Screen.Height]), mtInformation, [mbOK], 0); RegisterHotkey(handle,1,MOD_CONTROL or MOD_ALT,72); RegisterHotkey(handle,2,MOD_CONTROL or MOD_ALT,83); RegisterHotkey(handle,3,MOD_CONTROL or MOD_ALT,67); end;
end. |
Hat jemand eine Idee?
Ich freue mich auf Antworten.
_________________ Hardware runs the world, software controls the hardware, code generates software - Have You already coded today?
|
|
WeBsPaCe
      
Beiträge: 2322
Erhaltene Danke: 1
FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
|
Verfasst: So 21.08.05 12:41
Ohne deinen Code angeguckt zu haben: Wenn du sagst, "wieder" sichtbar machen, dann mach doch einfach eine Schleife rein, die überprüft, ob das Ding Visible ist oder nicht. Wenn ja, wieder Invisible machen, wenn nein, weiter. 
|
|
Christian V. 
      
Beiträge: 311
Win Xp Prof
Turbo Delphi 2005
|
Verfasst: So 21.08.05 12:50
Nun, danke für die schnelle Antwort, aber ich habs nun so gemacht:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| begin if (isWindowVisible(h2)) or (h2<>0) then else begin hnd := GetForegroundWindow; ShowWindow(hnd,SW_MINIMIZE); ShowWindow(hnd,SW_HIDE); h2:=hnd;
end; end; |
_________________ Hardware runs the world, software controls the hardware, code generates software - Have You already coded today?
|
|
WeBsPaCe
      
Beiträge: 2322
Erhaltene Danke: 1
FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
|
Verfasst: So 21.08.05 12:56
Na, dann wird sich das Spiel doch aber auch nicht selber wieder angezeigt haben, oder?!  Egal, Hauptsache es funktioniert.
slt, WeBBy
|
|
huhn
      
Beiträge: 272
Erhaltene Danke: 1
WIN XP
D7Pers
|
Verfasst: So 21.08.05 13:01
erkundige dich mal nach SetWindowLong(), mit dem kann man viele lustige sachen machen
dann hab ich das noch gefunden, vielleicht hilfts dir!musst halt noch angleichen(anstatt das laufende programm, eben das spiel)
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| var wnd: HWND; begin wnd := FindWindow('Progman', 'Program Manager'); wnd := FindWindowEx(wnd, 0, 'SHELLDLL_DefView', nil); wnd := FindWindowEx(wnd, 0, 'SysListView32', nil); Windows.SetParent(Handle, wnd); end; |
mfg huhn
_________________ Quod Erat Demonstrandum-Was zu beweisen war! *THX to Chrissivo!*
|
|
|