Einzelnen Beitrag anzeigen

Destroyer446

Registriert seit: 17. Jan 2011
67 Beiträge
 
#6

AW: Key an anderes Fenster senden das nicht aktiviert ist?

  Alt 21. Jul 2011, 12:26
Mhhh...
Ich habs jez so probiert:
Delphi-Quellcode:
var
 FensterHandle, MemoHandle: HWND;
begin
 FensterHandle := FindWindow('', 'Neu Textdokument - Editor');
 MemoHandle := FindWindowEx(MemoHandle, FensterHandle, 'TMemo', 'Neu Textdokument - Editor');
 SendMessage(MemoHandle, WM_CHAR, Ord('C'), 0);
Nur leider klappt das nit^^
Kapiere das mit FindWindowEx noch nit so ganz^^

[Edit: 21.Juli 2011 um 13:37]
Ich habe jeze ma geguckt was denn
Zitat:
EnumChildWindows
bringt, das ist das Resultat:
Delphi-Quellcode:
type
  PWindows = ^TWindows;
  TWindows = record
    WindowHandle: HWND;
    WindowText: string;
  end;
  TForm1 = class(TForm)
    TreeView1: TTreeView;
    procedure FormCreate(Sender: TObject);
    procedure FormResize(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  PNode, CNode: TTreeNode;
  AWindows: PWindows;

implementation

{$R *.dfm}

function EnumChildWindowsProc(Wnd: HWnd; Form: TForm1): Bool; export;
  {$ifdef Win32} stdcall; {$endif}
var
  Buffer: array[0..99] of Char;
begin
  GetWindowText(Wnd, Buffer, 100);
  //if StrLen(Buffer) 0 then
  if StrPas(Buffer) = 'then Buffer := 'Empty';
  new(AWindows);
  with AWindows^ do
  begin
    WindowHandle := Wnd;
    WindowText := StrPas(Buffer);
  end;

  CNode := Form1.TreeView1.Items.AddChildObject(PNode,
                 AWindows^.WindowText + ':' +
                 IntToHex(AWindows^.WindowHandle, 8), AWindows);
  if GetWindow(Wnd, GW_CHILD) = 0 then
  begin
    PNode := CNode;
    Enumchildwindows(Wnd, @EnumChildWindowsProc, 0);
  end;
  Result := True;
end;

function EnumWindowsProc(Wnd: HWnd; Form: TForm1): Bool;
  export; {$ifdef Win32} stdcall; {$endif}
var
  Buffer: array[0..99] of Char;
begin
  GetWindowText(Wnd, Buffer, 100);
  //if StrLen(Buffer) 0 then
  if StrPas(Buffer) = 'then Buffer := 'Empty';
  new(AWindows);
  with AWindows^ do
  begin
    WindowHandle := Wnd;
    WindowText := StrPas(Buffer);
  end;

  PNode := Form1.TreeView1.Items.AddObject(nil, AWindows^.WindowText + ':' +
    IntToHex(AWindows^.WindowHandle, 8), AWindows);
  EnumChildWindows(Wnd, @EnumChildWindowsProc, 0);
  Result := True;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 EnumWindows(@EnumWindowsProc, Longint(Self));
end;
Da kommen ganz viele ´Emtpys´... Was heißt das? ^^

PS: Den Code habe ich nicht selber gescriptet sondern von [Klick mich] geholt^^
[/Edit]
[Edit2]
Was ist das Parentwindow? Bzw. Wie bekomme ich das Handle vom "Eltern-Fenster" wie der Google-translator meint^^
Dankööö^^
[/Edit2]

Danke...^^

Geändert von Destroyer446 (21. Jul 2011 um 12:43 Uhr)
  Mit Zitat antworten Zitat