Autor Beitrag
Hippo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 49



BeitragVerfasst: Do 07.07.05 16:06 
Hallo,

ich würde gerne einen Text aus einem Fenster lesen, von dem ich das Handle kenne, das geht irgendwie mit GetText, aber ich weiß nicht wie genau. Und kann es sein, dass man da nur einen Integer-Wert zurückkriegt?
Danke für die Hilfe.
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Do 07.07.05 16:17 
Text aus einem Fenster klingt für mich eher nach GetWindowText. Meinst du sowas?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var Buf:array of Char;
begin
 SetLength(Buf,GetWindowTextLength(MeinHandle)+1);
 GetWindowText(MeinHandle,PChar(Buf),length(Buf));
 ShowMessage( StrPas(PChar(Buf)) );
end;


Gruß,
maxk

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.


Zuletzt bearbeitet von maxk am Do 07.07.05 16:19, insgesamt 1-mal bearbeitet
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Do 07.07.05 16:17 
Schonmal die Forensuche oder MSDN zu Rate gezogen?

AXMD
Hippo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 49



BeitragVerfasst: Fr 08.07.05 20:04 
Die Suche hab ich schon benutzt. Ich habs jetzt versucht, aber es geht nicht.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.Button1Click(Sender: TObject);
var
  wnd: HWND;
  Buf:array of Char;
begin
  wnd :=  FindWindow('J', 'Fenstername');
  wnd :=  FindWindowEx(wnd, 0, 'SunAwtCanvas', nil);
  wnd :=  FindWindowEx(wnd, 0, 'SunAwtCanvas', nil);

  if wnd <> 0 then
  begin
  SetLength(Buf,GetWindowTextLength(wnd)+1);
  GetWindowText(wnd,PChar(Buf),length(Buf));
  Memo1.text:=StrPas(PChar(Buf));
  end;
end;



Weiß jemand wo der fehler liegt?
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Fr 08.07.05 22:51 
Es sieht so aus, als würde sich der Text auf einem Canvas befinden. Dort wird jedoch kein Text mittels SetWindowText dargestellt, sondern durch einfaches Zeichen auf das Canvas. Du kommst also (abgesehen von einer Texterkennung) nicht an den Text ran.
Ansonsten einfach mal durchsteppen und kontrollieren, ob wnd immer den richten Wert hat. Es sieht ein bisschen komisch aus, da Zeile 7 und 8 identisch sind.

Gruß,
maxk

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
Hippo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 49



BeitragVerfasst: Sa 09.07.05 11:00 
Ich habe den Code mit XSpy rausbekommen, das Programm machts bestimmt richtig.

Texterkennung - ich hab schon gesucht aber nichts gefundeb, gibt es da irgendwo etwas darüber?
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 09.07.05 12:12 
GetWindowText kann nur den Text von Kontrols im eigenen Prozess auslesen, nimm Suche im MSDN WM_GETTEXT.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Sa 09.07.05 20:25 
user profile iconHippo hat folgendes geschrieben:
Ich habe den Code mit XSpy rausbekommen, das Programm machts bestimmt richtig.

Naja, ein Problem mit der Erzeugung vom FindWindow-Code gibt es noch, dass ich noch nicht gefixt hab - steht aber auch dabei. Wenn es mehrere Child-Fenster derselben Fensterklasse gibt, die nicht durch den Fenster-Text oder die Control-ID unterschieden werden können, dann ist es nicht eindeutig bestimmt, welches Fenster beim Aufruf von FindWindow() zurückgegeben wird. Deswegen werden im Treeview oben auch alle Child-Fenster eingeblendet, damit man das überprüfen kann.

Gruß, Motzi

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: So 10.07.05 06:40 
Dann nimm mal meinen WinSpy und lasse den Code erzeugen.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 10.07.05 10:53 
@Toms: wo gibts denn die neueste Version deines WinSpy? Die letzte Version die ich hab hat dieses Problem nämlich auch..

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: So 10.07.05 11:42 
user profile iconMotzi hat folgendes geschrieben:
@Toms: wo gibts denn die neueste Version deines WinSpy? Die letzte Version die ich hab hat dieses Problem nämlich auch..


Hier:

www.delphi-forum.de/...amp;highlight=winspy


Falls das Problem immer noch besteht, gib mir bitte ein Control in einer Standard Windows Anwendung an, welches gefunden werden sollte. So kann ich am einfachsten bugfixen.