Ver Mensaje Individual
  #3  
Antiguo 13-07-2015
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola deliriun.

El tema se ha tratado anteriormente,
Un ejemplo mas concreto:
Código Delphi [-]
...
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    FAppTitle: string;
    procedure SendKeyToApp(const Key: Word; KeyUp: DWORD = 0);
  public
    property AppTitle: string read FAppTitle write FAppTitle;
  end;
var
  Form1: TForm1;

implementation

procedure TForm1.SendKeyToApp(const Key: Word; KeyUp: DWORD = 0);
var
  H : HWND;
  TI: TInput;
begin
  H := FindWindow(nil, PChar(FAppTitle));
  if H <> 0 then
  begin
    SetForegroundWindow(H);
    EnableWindow(H, False);
    ZeroMemory(@TI, SizeOf(TI));
    TI.Itype      := INPUT_KEYBOARD;
    TI.ki.wVk     := Key;
    TI.ki.dwFlags := KeyUp;
    SendInput(1, TI, SizeOf(TI));
    EnableWindow(H, True);
    SetForegroundWindow(Handle);
  end;
end;


// Enviar el caracter "A" al Bloc de notas
procedure TForm1.Button1Click(Sender: TObject);
begin
  AppTitle := 'Sin título: Bloc de notas';
  SendKeyToApp(VK_SHIFT);
  SendKeyToApp(Ord('A'));
  SendKeyToApp(Ord('A'), KEYEVENTF_KEYUP);
  SendKeyToApp(VK_SHIFT, KEYEVENTF_KEYUP);
end;

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 13-07-2015 a las 21:18:26.
Responder Con Cita