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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:42:37+00:00 2026-06-03T04:42:37+00:00

I have this bit of code which uses SendInput to send a key press

  • 0

I have this bit of code which uses SendInput to send a key press but it doesn’t work for when I want to long hold a key (eg long hold ‘a’ would return ‘aaaaaaaaa’ in notepad).

Now I have looked all over google and the only way I can see to get around this is to keep sending the input if I want a long hold. I don’t want to do that as this will just simulate ‘a’ being pressed over and over again.

keyboard.wVk = 0;
keyboard.wScan = MapVirtualKey(key, 0);

keyboard.dwFlags = KEYEVENTF_SCANCODE;

if (index_vector_no)
    pressed[index_vector_no] = true;

keyboard.dwExtraInfo = 0;

input.type = INPUT_KEYBOARD;
input.ki = keyboard;

SendInput(1, &input, sizeof (input));

So I would like some answers to the following questions:

A) Am I right in thinking there is no way around this using SendInput and why doesn’t it work for long hold?

B) What is an alternative method for successfully being able to send key down and key up signals. Preferably sending the keys to windows and not just to a particular application.

C) Is there a good lightweight C++ library I can use that handles global keyboard and mouse simulation?

Thanks in advance! =)

EDIT: Take a look at this post for more details of my problem: http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_20833788.html

  • 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-03T04:42:38+00:00Added an answer on June 3, 2026 at 4:42 am

    Repeating keystrokes is a feature of the keyboard controller, not of Windows or SendInput. You can certainly emulate it with a timer, repeatedly calling SendInput().

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

Sidebar

Related Questions

I have written quite a bit of code which uses the Linq2Sql table relationships
This question is a bit long due the source code, which I tried to
I can't quite figure out why. But I have some code which uses PIE.htc
I have a code which uses bit-fields declared as follows typedef struct my{ const
I have this bit of code, public static List<string> GetSentencesFromWords(List<string> words, string fileContents) {
ok i got this problem. i have this routes: (code bit change) File:/home/dotcloud/current/config/routes.js exports.routes
I use this bit of code to feed some data i have parsed from
its a little bit hard to understand. in the header.php i have this code:
I have the following bit of code, simply: $(function() { $('a.add-photos-link').live('click', function(e) { $(this).colorbox({
I have a bit of php code like this: $test = <!--my comment goes

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.