Posted By: dzemen () on 'CZprogram'
Title:     Re: Jak odeslat stisk klavesy do jine aplikace
Date:      Fri Oct 22 13:08:02 2004

> Zdravim,
> poradite nekdo, jak odeslat do jine aplikace stisky klaves?
> Windows, bud VC6.0 nebo VB6.0 (stejne to bude asi neco z API).
> Diky
> 
> v
> Ceny

Musis pouzit AttachThreadInput, jinak to asi nepujde. Kdysi jsem to napsal, 
ale mam to doma, takze si to musis najit na Googlu.

V Delphi se to dela asi takto (myslim):

  hOtherWin := GetForegroundWindow;
  OtherThreadID := GetWindowThreadProcessID( hOtherWin, @aDwordvar);
  
  If AttachThreadInput( GetCurrentThreadID, OtherThreadID, True ) Then
  try
    hFocusWin := GetFocus;
    If hFocusWin <> 0 Then 
      ...send keystrokes to window
  finally
    AttachThreadInput( GetCurrentThreadID, OtherThreadID, False );
  end;

Toto je samozrejme posilani do prave aktivniho okna, kdyz bys chtel do jineho, 
musis pouzit FindWindow nebo EnumWindows, aby si ho nasel. 

Dzemen

Search the boards