Ver Mensaje Individual
  #6  
Antiguo 05-09-2015
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Reputación: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Este código con la API SendInput, es preferible al uso de keybd_event

Código Delphi [-]
procedure SimKey(VK: BYTE; Down: boolean);
var
  Input: TInput;
begin
  ZeroMemory(@Input, sizeof(Input));
  Input.iType:= INPUT_KEYBOARD;
  Input.ki.wVk:= VK;
  Input.ki.wScan:= MapVirtualKey(VK, 0);
  Input.ki.dwFlags:= KEYEVENTF_EXTENDEDKEY;
  if not Down then
    Input.ki.dwFlags:= Input.ki.dwFlags or KEYEVENTF_KEYUP;
  windows.SendInput(1, tagINPUT(Input), sizeof(TInput));
end;

Ejemplo de uso:
Código Delphi [-]

SimKey(VK_CONTROL, true);
SimKey('D', true);
SimKey(VK_CONTROL, false);
SimKey('D', false);


Saludos.
Responder Con Cita