Autor Beitrag
seddto
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Di 13.04.04 12:42 
Hallo,

Ich möchte gerne folgendes machen:

Mit einem On-timer Ereignis soll in bestimmten Intervallen der Name des aktiven Fensters festegstellt werden. Dann soll geprüft werden ob im Fensternamen der Begriff Google vorkommt ( Es geht also darum zu prüfen ob der user gerade etwas über google sucht...) Weiss jemand wie ich das mit FindWindow am besten mache?
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 13.04.04 13:53 
Nimm doch einfach "GetForegroundWindow".
andy09071978
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33

Win XP, Win 2000
D7 Prof
BeitragVerfasst: Di 13.04.04 14:16 
Hi seddto,

probier mal folgenden Code

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TForm1.Timer1Timer(Sender: TObject);
var
  H: HWND;
  Buffer: Array[0..255] of Char;
begin
  //Aktives Window-Handle bestimmen
  H := GetForegroundWindow;

  //Window-Text auslesen
  GetWindowTextA(H, Buffer, Pred(SizeOf(Buffer)));

  //Window-Handle ausgeben
  Form1.Label1.Caption := IntToStr(H);

  //Window-Text ausgeben
  Form1.Label2.Caption := Buffer;
end;


Gruß
seddto Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Di 13.04.04 17:41 
Danke! Werd ich gleich mal ausprobieren! :)
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 13.04.04 19:06 
Bezüglich GetWindowText:
MSDN hat folgendes geschrieben:
To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
andy09071978
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33

Win XP, Win 2000
D7 Prof
BeitragVerfasst: Mi 14.04.04 07:46 
@Motzi: und wie bekomm ich dann den Text ??? Doch nich über ne Message...
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 14.04.04 11:12 
Doch..! Eben über WM_GETTEXT..!
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
function MyGetWindowText(Window: hWnd): String;
var
  dwSize: DWord;
begin
  dwSize := SendMessage(Window, WM_GETTEXTLENGTH, 0, 0) + 1;
  SetLength(Result, dwSize);
  dwSize := SendMessage(Window, WM_GETTEXT, dwSize, Integer(Pointer(Result)));
  SetLength(Result, dwSize);
end;

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
andy09071978
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33

Win XP, Win 2000
D7 Prof
BeitragVerfasst: Do 15.04.04 07:45 
:) kurz noch ne andere Frage:

Wie sieht das Gegenstück so einer Message aus ?
Also eine Funktion, die einen String sendet (evtl. in einem Pointer verpackt) ?
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Do 15.04.04 08:21 
SendMessage + WM_SETTEXT
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 15.04.04 08:31 
andy09071978 hat folgendes geschrieben:
@Motzi: und wie bekomm ich dann den Text ??? Doch nich über ne Message...

Du solltest den Begriff Message vielleicht nicht als Nachricht interpretieren, die du abschickst und auf die du keine Antwort erhältst. Sieh es eher als Befehl/Anweisung, mit der du den Empfänger dazu bringst, in der gewünschten Form zu reagieren. Viele Nachrichten sind eben nur in Funktionen/Prozeduren gekapselt, so dass du im Normalfall gar nicht merkst, dass du es mit einer Nachricht zu tun hast. Nimm "SetWindowText"/"GetWindowText" - dahinter stecken auch bloß WM_SETTEXT/WM_GETTEXT.