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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:45:57+00:00 2026-06-04T16:45:57+00:00

I am writing a program, and it is going well so far, however I

  • 0

I am writing a program, and it is going well so far, however I have an issue with the following code:

void Send(string content) {
    unsigned int size = content.size();
    INPUT *inputs = new INPUT[size];

    for (unsigned int i = 0; i < size; i++) {
        inputs[i].type = 1;
        inputs[i].ki.wVk          = 0;//LOWORD(VkKeyScan(content.at(i)));
        inputs[i].ki.wScan        = content.at(i);
        inputs[i].ki.dwFlags      = KEYEVENTF_UNICODE | KEYEVENTF_SCANCODE;
        inputs[i].ki.time         = 0;
        inputs[i].ki.dwExtraInfo  = ::GetMessageExtraInfo();
    }

    SendInput(size, inputs, sizeof(*inputs)*size);

    for (unsigned int i = 0; i < size; i++) {
        inputs[i].ki.dwFlags &= KEYEVENTF_KEYUP;
    }

    SendInput(size, inputs, sizeof(*inputs)*size);
}

What I am trying to achieve is being able to send input like this:

Send(string("Hello World!"));

However, it does everything it should not, such as moving the cursor even though the type is set to the keyboard. At most, it outputs one character.
As you see on line 2, I have an INPUT array. However, when I view this in the debugger, it appears simply as a single INPUT structure, rather than an array of structures.

I am using g++ with gdb debugger + Code::Blocks IDE.

Thanks guys.

EDIT

NEW CODE:

void Send(string content) {
    unsigned int size = content.size();
    INPUT *inputs = new INPUT[size];
    INPUT curr[1];

    ZeroMemory(inputs, sizeof(*inputs)*size);

    for (unsigned int i = 0; i < size; i++) {
        inputs[i].type = 1;
        inputs[i].ki.wVk          = 0;//LOWORD(VkKeyScan(content.at(i)));
        inputs[i].ki.wScan        = content.at(i);
        inputs[i].ki.dwFlags      = KEYEVENTF_UNICODE | KEYEVENTF_SCANCODE;
        inputs[i].ki.time         = 0;
        inputs[i].ki.dwExtraInfo  = ::GetMessageExtraInfo();
    }

    for (unsigned int i = 0; i < size; i++) {
        curr[0] = inputs[i];            // Current input
        int a = ::SendInput(1, (INPUT*)&curr, sizeof(curr));

        inputs[i].ki.dwFlags &= KEYEVENTF_KEYUP;

        curr[0] = inputs[i];
        int b = ::SendInput(1, (INPUT*)&curr, sizeof(curr));

        TCHAR *buff = new TCHAR[3];

        wsprintf(buff, "%i %i", a, b);

        MessageBox(NULL, buff, "SendInput return vals", 0);
    }
}

This still sends nothing.

  • 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-04T16:45:59+00:00Added an answer on June 4, 2026 at 4:45 pm

    I suppose it is because you are sending only KEYDOWN messages. You might want to try sending first KEYDOWN, then KEYEVENTF_KEYUP for the same character.

    [edit for NEW CODE]

    few hints:

    1. remove KEYEVENTF_SCANCODE
    2. string is for char strings, for UNICODE use wstring
    3. before testing your function make sure that some app with editbox is foreground, for example Notepad
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a program to add some code to html files I was going
Im writing a program that should read input via stdin, so I have the
I have some C++ code that is writing to a socket that is being
I have a weird problem with aRuby program I'm writing. Basically the idea is
I'm writing a program for some homework that's going to entail some forking, but
Can we determine if a program is well working by considering the following questions?
I am writing a simple Java program to send mail, but am getting errors.
When writing a Java program, do I have influence on how the CPU will
I am writing a program that will create users in bulk, I have a
So here's the problem I am writing a program that is going to look

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.