Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8408805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:43:58+00:00 2026-06-09T23:43:58+00:00

I borrowed someones code that sends a key event to another process (hWnd). Here

  • 0

I borrowed someones code that sends a key event to another process (hWnd). Here is the definition of that function:

public static void SendKey(ushort key, IntPtr hWnd)
{
    SetActiveWindow(hWnd);
    SendMessage(hWnd, WM_KEYDOWN, key, 0);
    SendMessage(hWnd, WM_KEYUP, key, 0);
}

Where SendMessage is taken from a DllImport:

//sends a windows message to the specified window
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, uint wParam, int lParam);

As you can see, the SendKey method takes a ushort value for the key to be sent.

Does anyone know where I can find these values? I.e. if the user pressed the “7” key and I wanted to forward it how to i go from the 7 key event/callback to a ushort value?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:43:59+00:00Added an answer on June 9, 2026 at 11:43 pm

    For sending ascii characters you can use type casting, here is the example:

    System.Convert.ToUInt16('7')

    For sending non ascii characters use virtual key codes. Reference can be found at
    MSDN

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a piece of code borrowed from the Endogine engine. It is supposed
This following code example is borrowed from MSDN here . I am not getting
I'm working with some code I borrowed from here which uses boost::call_once to make
I borrowed code from thumbnail.js modified it so that it takes screenshot of the
I have a class that I borrowed from here that loads and image from
Take the code below, adapted from this question : //Borrowed from another question because
I have some code that I borrowed from a long while ago that sets
It seems that almost all features in C# were borrowed from another languages (OOP
I borrowed this from another question about fragmentation, but I'm not bothered by that.
first question here! I have written and borrowed code to form a IP Address

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.