🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
2 messages
2 total messages Started by DeKayA Wed, 18 Oct 2006 17:33
keyboard event for special characters
#2947
Author: DeKayA
Date: Wed, 18 Oct 2006 17:33
55 lines
2183 bytes
Maybe I am doing this all wrong!
Code follows the narration...

I am retrieving characters from a listbox and sending them one at a
time to a running DOS program.   (win2k CMD actually)
The program was selected in a previous routine and the characters are
indeed sent to the open CMD prompt.

I have noticed all character must be in upper case for the cmd to
receive them so, as an example the text box has the following lines in
it.

TELNET MAIL.SOMEWHERE.COM 25
HELO ME

This works but the "." is not interpreted correctly 
I discovered that a lower case "n" is interpreted as a .

MAIL FROM: SOMEONE@SOMEWHEREnNET  // notice the "n" for a period
RCPT TO: dekaya@SOMEWHEREnNET    

But that is not the correct approach because I can't send the needed @
symbol

DATA
From: RemoteAccess
To: SOMEONE@SOMEWHERE.NET
Subj: What is My IP Address


Bottom line:  How do I send  CR/LF   and special characters



---------------------------------------------------------

void __fastcall TForm1::SendKey(String SCharacter)
{
  HWND handle;
  handle = FindWindow(NULL, EditTargetApp->Text.c_str());
  if(handle != NULL)
  {
  char *character = SCharacter.c_str();

  // bring it to the front
     SetForegroundWindow(handle);

    // send the letter to the program; parameter MUST be uppercase
    
    keybd_event(*character, 0, 0, 0);
    keybd_event(*character, 0, KEYEVENTF_KEYUP, 0);
  }

}
Re: keyboard event for special characters
#2950
Author: Bob Gonder
Date: Thu, 19 Oct 2006 02:54
30 lines
1865 bytes
DeKayA@bellsouth.net wrote:

>Maybe I am doing this all wrong!

Could be.

>  char *character = SCharacter.c_str();
>    keybd_event(*character, 0, 0, 0);

It looks like keybd_event wants a vitual key code as the first
parameter, not an ASCII character.
Take a look at VkKeyScan()

keybd_event( VkKeyScan(*character), 0, 0, 0 );

or

PostMessage( handle, WM_KEYDOWN , VkKeyScan(*character), 0 );
PostMessage( handle, WM_KEYUP , VkKeyScan(*character), 0xC0000000 );


>Bottom line:  How do I send  CR/LF   and special characters

Search your Help for "Virtual-Key Codes" for a list.
VK_RETURN
\n is undefined

You already discovered that period is
VK_DECIMAL	6E	Decimal key 
otherwise known as ASCII  'n'
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads