Autor Beitrag
delphi-n00bz
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Do 29.05.03 16:21 
hi leute,

ich möchte die installation einer arbeitsumgebung so weit wie möglich automatisieren, d.h. seriennummer, verzeichnisse usw bei setup programmen automatisch eingeben lassen. jetzt ist nur die frage, wenn z.b. die delphi installation läuft, wie kriege ich dann das handle von dem setup fenster heraus? ich hab schon mal ein programm gesehen, das hiess glaube ich x-spy, das listet auch alle handles auf.

danke für eure hilfe und mfg
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 29.05.03 16:54 
Mittels FindWindow kannst du dir ein Fenster-Handle besorgen (sofern du Klassenname oder Fenstertext kennst). Mittels FindWindowEx kannst du dir dann noch die Handles auf die Kind-Fenster (zB Edit-Felder für Seriennummer ect.) besorgen...

BTW: Ja, das Programm heißt X-Spy und stammt von mir: www.x-spy.net ;)

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



BeitragVerfasst: Do 29.05.03 17:04 
erstmal danke,

das heisst also ohne fenstername läuft nix. von den class dingern hab ich keine ahnung
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 29.05.03 20:33 
Jedes Fenster hat einen Klassennamen. Es gibt verschiedene Klassen und ein Fenster stammt immer von einer bestimmten Fenster-Klasse ab. Wenn du nun den Klassennamen eines Fensters kennst kannst du das Fenster mittels FindWindow suchen (und finden ;) ). Schau dir einfach mal im X-Spy die Fenster-Liste an, dort hast du in der Auflistung das Fenster-Handle, den Klassennamen und den Fenstertext...

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 31.05.03 15:40 
Und dann würd eich beten, dass die Edits eindeutige ID's haben, denn dannkannst du dir das Handle mit GetDlgItem besorgen, ansonsten wird es etwas komplizierter.
delphi-n00bz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Do 05.06.03 14:31 
moin,

soweit, sogut. ich hab das alles hinbekommen, fensterhandle besorgen mit findwindow, danach tbutton finden mit findwindowex und danach mal so spasseshalber mit sendmessage den button geclickt. aber jetzt ist halt das problem, wenn 2 oder mehr buttons auf dem form sind. wie kann ich die unterscheiden? er nimmt immer den, der als letztes auf dem form plaziert worden ist.
BoMbY
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Do 05.06.03 14:50 
google hilft (jedenfalls um ein fenster einfach zu finden):

ausblenden volle Höhe Quelltext
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:
function FindMatchingWindows(SearchFor: string; AtBeginning: boolean; var FoundWindows: TStringList): longint;

{Search window list for all Windows where the title contains or begins
 with (AtBeginning) SearchFor. Returns a TStringList with the title of the
 found windows as string and the window-Handle as Object.
 It is up to you to create and free the TStringList}

var
  hWndFirst, hWndCurWin, hWndDesk: HWnd;
  szWinText: pChar;
  WinText: string;
  foundAt: byte;
begin
  hWndDesk:= GetDesktopWindow;
  {This ist the parent of alle top-level windows}
  if hWndDesk <> 0 then
        hWndCurWin := GetWindow(hWndDesk,GW_CHILD)
  else
        {place error handling here}
        exit;
  if not assigned(FoundWindows) then
        {you have to create Stringlist before passing the
         variable to this function}
        exit;
  getMem(szWinText,256);
  hWndFirst:= hWndCurWin;
  while (hWndCurWin <> 0) do
  begin
    GetWindowText(hWndCurWin, szWinText,255);
    WinText:= strpas(szWinText);
    if SearchFor = '' then
    begin
        if WinText = '' then Wintext := format ('Fenster Nr. %d (Ohne Titel)',[hWndCurWin]);
        FoundWindows.addObject(WinText,TObject(hWndCurWin))
    end
    else
    begin
      foundAt:= pos(SearchFor, WinText);
      if (not atBeginning and (foundAt > 0)) or (foundAt = 1) then
      begin
        FoundWindows.addObject(WinText,TObject(hWndCurWin));
      end;
    end;
    hWndCurWin := GetWindow(hWndCurWin,GW_HWNDNEXT);
  end;
  freeMem(szWinText,256);
  result := FoundWindows.count;
end;


Wenn du einen Handle zu dem Button bekommst, kannst du auch mit GetWindowText die Caption bekommen.

m.f.g.
BoMbY
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 05.06.03 18:19 
BoMbY hat folgendes geschrieben:
Wenn du einen Handle zu dem Button bekommst, kannst du auch mit GetWindowText die Caption bekommen.

Das glaube ich nicht Tim. Bob Vila schreibt dazu:
Zitat:

However, GetWindowText cannot retrieve the text of a control in another application.

Also wenn du den Text brauchst dann schick ein WM_GETTEXT.
BoMbY
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Fr 06.06.03 12:06 
@Luckie: Ja, lese auch gerade das es so in der MSDN steht, obwohl die Funktion auch nichts anderes macht als eine WM_GETTEXT Message zu verarbeiten... ???

Zitat:
[...] GetWindowText causes a WM_GETTEXT message to be sent to the specified window or control. [...]


msdn.microsoft.com/l...ns/getwindowtext.asp

m.f.g.
BoMbY
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Fr 06.06.03 12:46 
Lies den ganzen Satz! ;)

MSDN hat folgendes geschrieben:
If the target window is owned by the current process, GetWindowText causes a WM_GETTEXT message to be sent to the specified window or control.

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



BeitragVerfasst: Fr 06.06.03 13:50 
servus,

also irgendwie reden wir aneinander vorbei :roll: , nehmen wir mal folgendes beispiel: report builder für delphi 5. ich lasse mich per timer informieren wenn ein fenster auftaucht mit der caption "druckvorschau". so dann bekomme ich von dem fenster das handle raus. bis dahin kein problem. so und jetzt möchte ich wissen wie ich das handle herauskriege von dem speedbutton(es sind 3 auf dem form) damit die ansicht 100% ausgewählt wird. es ist halt nicht das problem nach einem button zu suchen, das problem ist nur da wenn mehrere button vorhanden sind. er findet immer nur einen.

vielen dank für eure hilfe