Einzelnen Beitrag anzeigen

hathor
(Gast)

n/a Beiträge
 
#2

AW: Software gesucht, die Fokus-Klau findet

  Alt 25. Jan 2014, 21:28
Vielleicht so:

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    ListBox2: TListBox;
    Timer1: TTimer;

    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


function EnumWindowsProc(wHandle: HWND; lb: TListBox): Bool; stdcall; export;
var
  Title, ClassName: array[0..255] of char;
begin
  Result := True;
  GetWindowText(wHandle, Title, 255);
  GetClassName(wHandle, ClassName, 255);
  if IsWindowVisible(wHandle) then
     lb.Items.Add(IntToStr(lb.Count +1)+' : '+ String(Title) + '-' + string(ClassName));
if GetForegroundWindow = wHandle then
begin
// ShowMessage(String(Title) + '-' + string(ClassName));
  Form1.ListBox2.Items.Add(IntToStr(lb.Count +1)+' : '+ String(Title) + '-' + string(ClassName));
end;
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
Listbox1.Clear;
Listbox2.Clear;
EnumWindows(@EnumWindowsProc, Integer(Listbox1));
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Listbox1.Clear;
EnumWindows(@EnumWindowsProc, Integer(Listbox1));
end;

Geändert von hathor (25. Jan 2014 um 21:40 Uhr)
  Mit Zitat antworten Zitat