| Autor |
Beitrag |
FriFra
      
Beiträge: 557
Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
|
Verfasst: So 13.02.05 13:05
Ich möchte in einer fremden Anwendung einen vorgegebenen Text ersetzen, dies gelingt mir jedoch nur zum Teil...
Bei Word, Lotus Notes und im Internet Explorer komme ich nicht weiter  ... Bei diesen Programmen habe ich jetzt einen "Blinkecode" drin -> das Control blinkt kurz auf  Ich hab aber keinen Plan, wie ich an den enthaltenen Text kommen soll.
Die native Einbindung von z.B. Word kommt nicht in Frage, da das ganze Programmunabhängig funktionieren soll!
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: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88:
| procedure TForm1.Timer1Timer(Sender: TObject); var AppHWnd: HWND; ThreadId: DWORD; FocusHWnd: HWND; ClassName: string; S0, S1: string; Rect: TRect; Canvas: TCanvas; Loop: integer; begin Timer1.Enabled := False; FocusHWnd := GetFocus; if not IsWindow(FocusHWnd) then begin AppHWnd := GetForegroundWindow; if AppHWnd <> Self.Handle then begin ThreadId := GetWindowThreadProcessId(AppHWnd, nil); if ThreadId <> 0 then if AttachThreadInput(GetCurrentThreadId, ThreadId, True) then begin FocusHWnd := GetFocus; AttachThreadInput(GetCurrentThreadId, ThreadId, False);
SetLength(ClassName, 512); SetLength(ClassName, GetClassName(FocusHWnd, PChar(ClassName), Length(ClassName)));
SetLength(S0, SendMessage(FocusHWnd, WM_GETTEXTLENGTH, 0, 0) + 1); if Length(S0) > 1 then begin Application.ProcessMessages; SetLength(S0, SendMessage(FocusHWnd, WM_GETTEXT, Length(S0), LPARAM(PChar(S0)))); S1 := StringReplace(S0, '###Hierhin###', 'Neuer Text', [rfReplaceAll]); if S0 <> S1 then SendMessage(FocusHWnd, WM_SETTEXT, Length(S1), LPARAM(PChar(S1))); end else begin Windows.GetClientRect(FocusHWnd, Rect); Rect.BottomRight := Point(Rect.Left + Rect.Right, Rect.Top + Rect.Bottom); Windows.ClientToScreen(FocusHWnd, Rect.TopLeft); Windows.ClientToScreen(FocusHWnd, Rect.BottomRight); Canvas := TCanvas.Create; try Canvas.Pen.Mode := pmNot; Canvas.Pen.Width := 5; Canvas.Handle := GetDC(HWnd_Desktop); try for Loop := 1 to 8 do begin Canvas.Polyline([Rect.TopLeft, Point(Rect.Right, Rect.Top), Rect.BottomRight, Point(Rect.Left, Rect.Bottom), Rect.TopLeft]); Sleep(100); end finally ReleaseDC(HWnd_Desktop, Canvas.Handle) end; finally Canvas.Free end; end; end; end; end;
if (ListView1.Items.Count = 0) or (ListView1.Items[ListView1.Items.Count - 1].Caption <> IntToStr(FocusHWnd) + '[' + ClassName + ']="' + Trim(S0) + '"') then begin ListView1.Items.BeginUpdate; ListView1.Items.Add; ListView1.Items[ListView1.Items.Count - 1].Caption := IntToStr(FocusHWnd) + '[' + ClassName + ']="' + Trim(S0) + '"'; ListView1.Items[ListView1.Items.Count - 1].MakeVisible(False); ListView1.Items.EndUpdate; end; Timer1.Enabled := True; end; |
_________________ Michael
(principal certified lotus professional - developer)
|
|
Handycommander
      
Beiträge: 1054
Windows XP Pro, Vista
Visual Studio 2008
|
Verfasst: Mo 14.02.05 13:46
Hallo,
ich glaub, deine Frage ist etwas zu ungenau formuliert!
Du willst also, in einem Programm, z.B. Internet-Explorer einen Text ersetzen? Label oder was?
MfG
Tobias
|
|
FriFra 
      
Beiträge: 557
Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
|
Verfasst: Mo 14.02.05 14:04
| Handycommander hat folgendes geschrieben: | Hallo,
ich glaub, deine Frage ist etwas zu ungenau formuliert!
Du willst also, in einem Programm, z.B. Internet-Explorer einen Text ersetzen? Label oder was?
MfG
Tobias |
Ungenau? Ich glaub, die meisten haben schon verstanden, was gemeint ist  ...
Ich meine beliebige Texteingabe-Felder, das kann z.B. das Notepad sein (da funzt es auch  ), oder Word, oder Lotus Notes, oder Outlook oder ein Textarea im IE oder irgend etwas anderes... egal, ich will den Text des Controls, welches gerade im Vordergrund ist und wo der Cursor drin steht...
_________________ Michael
(principal certified lotus professional - developer)
|
|
|