trichview.com

trichview.support




Re: Keyboard Event


Return to index


Author

Message

Marc

Posted: 01/30/2004 0:53:30


A bit off-topic, but here you go:


procedure SimulateKey(Code: UINT; Down: Boolean);

const

  KeyFlag : array[Boolean] of UINT = (KEYEVENTF_KEYUP, 0);

begin

  Keybd_Event(Code, MapVirtualKey(Code, 0), KeyFlag[Down], 0);

end;


procedure NormalKeyPress(C: Char);

var

  KeyCode,

  Shift  : UINT;

  ShiftPressed:boolean;

begin

   {get keyboard character}

  KeyCode := vkKeyScanEx(C, GetKeyboardLayout(0));

  begin

     ShiftPressed:=false;

     Shift := Hi(KeyCode);

      {check if SHIFT is required}

     if Shift in [1, 7] then ShiftPressed := True;

      {Send Shift Key if needed}

     if ShiftPressed then SimulateKey(VK_SHIFT, True);

      {send keypress, keydown=true}

     SimulateKey(LoByte(KeyCode),true);

      {send keypress, keydown=false}

     SimulateKey(LoByte(KeyCode),false);

      {release shift if required}

     if ShiftPressed then SimulateKey(VK_SHIFT, False);

  end;

end;


NormalKeyPress('@');


..



"Jim" <aa2389@yahoo.com> wrote:

>

>Hi,

>I am sorry to ask a delphi general question here, but I want to output some

>letters to RVEdit when a certain button is pressed. I have a button in my

>application and when click will output a certain email address to RVEdit.

>The problem I have is that the following codes:

>

>keybd_event(ORD'E',0, 0, 0);

> will give the letter E. BUT I want to output other characters such as @(assigned

>at) to TRVEdit.

>

>The codes:keybd_event(ORD'@',0, 0, 0); WILL NOT GIVE THE ASSIGN AT CHARACTER.

>

>Sergey, can you please point out where did I go wrong. If possible pls give

>the correct codes.

>

>Thank you for your kindness.

>

>





Powered by ABC Amber Outlook Express Converter