Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Oct : WriteConsoleInput, VK_LEFT, dwControlKeyState problem

www.cryer.info
Managed Newsgroup Archive

WriteConsoleInput, VK_LEFT, dwControlKeyState problem

Subject:WriteConsoleInput, VK_LEFT, dwControlKeyState problem
Posted by:"Rich" (someo..@somewhere.com)
Date:25 Oct 2005 09:15:11 -0700

Hi,
I'm using D5.01, and attempting to "send" an <ALT><LEFT> keystroke
combination to a console.  If dwControlKeyState is 0, then the VK_LEFT
is properly received.  However, if dwControlKeyState is
LEFT_ALT_PRESSED, or RIGHT_ALT_PRESSED, then the console app does not
seem to receive the key events.  When typing <ALT><LEFT> directly into
the console, this console app moves the cursor to the beginning of the
current input field.

TIA, Rich

Here's the code in use:

Procedure TWF2CONform.SendAltLeftToConsole;
Var
  flag: DWORD;
  event1, event2: TInputRecord;
begin

    fillchar( event2, sizeof(event2), 0 );
    event2.EventType := KEY_EVENT;
    event2.Event.KeyEvent.wRepeatCount := 0;
    event2.Event.Keyevent.AsciiChar := #0;
    sh := VK_LEFT;
    event2.Event.Keyevent.wVirtualKeyCode := sh;
    event2.Event.Keyevent.wVirtualScanCode := MapVirtualKey(LOBYTE(sh),
0);
    event2.Event.Keyevent.dwControlKeyState := RIGHT_ALT_PRESSED;
    event2.Event.KeyEvent.bKeyDown := true;
    WriteConsoleInput( hConIn, event2, 1, flag );
    event2.Event.KeyEvent.bKeyDown := false;
    WriteConsoleInput( hConIn, event2, 1, flag );

end;

Glossary

Replies:

www.cryer.info
Managed Newsgroup Archive