Autor Beitrag
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Fr 08.12.06 23:56 
Hi,
Ich habe einen Timer, der nach drei Sekunden Windows.GetFocus abfrägt, und anzeigt. Wenn der Curser in meiner eigenen anwendung bleibt, dann bringt die funktion einen akzeptablen wert. Wenn ich aber den Curser in eine Fremdanwendung setzte, dann ist das Ergebnis immer 0.

Ich hoffe ihr könnt mir helfen, danke schon mal
Jakob
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 09.12.06 02:16 
Lesen bildet:
Zitat:
The GetFocus function retrieves the handle to the window that has the keyboard focus, if the window is attached to the calling thread's message queue.


Abhilfe: Suche im MSDN ATTACHTHREADINPUT.
Jakob Schöttl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Sa 09.12.06 09:43 
Kannst du mir bitte noch sagen, was die ThreadID ist, und wo die eigene gespeichert ist, und mit welcher funktion ich die vom Ziel-Fenster rauskriegt?

Ich hab zwar hier bei ActiveVB VisualBasic Code gefunden, aber der hilft mir nur beschränkt weiter.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 09.12.06 12:24 
Jakob Schöttl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Mi 13.12.06 14:33 
Danke Luckie. Jetzt hab ichs so geschafft:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var OtherThreadID: Cardinal;
    TargetNil: Boolean;
//...  
begin
  Thread1 := GetWindowThreadProcessId(Self.Handle, OtherThreadID);
  Thread2 := GetWindowThreadProcessId(GetForegroundWindow, OtherThreadID);
  TargetNotNil := False;
  If Thread1 <> Thread2 Then TargetNotNil := AttachThreadInput(Thread2,Thread1, True);
  if TargetNotNil then begin
    Options.TargetHandle := Windows.GetFocus;
      //jetzt weiß man das Handle des Ziels...
    end;    
end;