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 6124311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:07:06+00:00 2026-05-23T16:07:06+00:00

I have been using SendKeys.Send() & SendKeys.SendWait() to send keys to the foreground program

  • 0

I have been using SendKeys.Send() & SendKeys.SendWait() to send keys to the foreground program (a program different from the application written).

I tried sending a continuous key-press by sending repeatedly the same key with a certain delay between them but the effect was not the same as a continuous keypress in that application.

My question is: How can I send a continuous key-press to a program? The effect of that keypress must be the same as pressing myself that key continuously in the application.

SOLUTION EDIT

The solution was to call the method:

[DllImport("User32.dll")]
static extern int SendMessage(IntPtr hWnd, uint wMsg, UIntPtr wParam, IntPtr lParam);

with the parameters obtained from:

public System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName(“process”);

p[0].MainWindowHandle is hWnd

and using Spy on the window:

right clicking on a message line in Spy shows the wMsg, wParam and lParam (all 3 in hexadecimal)

SendMessage(p[0].MainWindowHandle, (uint)0x0100, (UIntPtr)0x00000041, (IntPtr)(0x001E0001));

By sending only one WM_KEYDOWN message the effect is as the key is pressed continuously. To stop the program acting as the key is continuously pressed i have to press that key on the keyboard and release it, so that WM_KEYUP is generated. Sending WM_KEYUP in the code gives an System.OverFlow “Arithmetic operation resulted in an overflow.” exception. Any ideea why that might happen?

Thanks for your replies: Ation and takrl

  • 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-05-23T16:07:07+00:00Added an answer on May 23, 2026 at 4:07 pm

    Try to use Win API SendMessage with WM_KEYDOWN and WM_KEYUP. Proper delay should be between this messaging. Also you could use PostMessage for async sending.

    [DllImport("User32.dll")]
                public static extern int SendMessage(IntPtr hWnd, uint msg, int wparam, int lparam);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using an MSI to install a WPF application using the .NET
I have been using Uploadify in my PHP application for the last couple months,
I have been using VS2010 without any issues, always on the same application. Suddenly
I have been using Selenium Webdriver successfully with JAR downloaded from their pages or
I have been using asp.net programming just from few months and I have to
I have been using php for quite a sometime now and encounter three different
I have a web application written in XUL and I've been trying to use
I have been using a mp3 file in my application for over 3 weeks
i have been using a modular structure for my zend framework application. This is
i have been using an actionListener to pass text from numerous TextFields into a

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.