1

I wanted to improve my SendInput() function but came across an error.

ERROR_INVALID_PARAMETER

87 (0x57)

The parameter is incorrect.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx

I am a bit confused which parameter should not be correct.

If I have forgotten something do not hesitate to ask.

INPUT in[6] = {0};

//Press Enter Key
in[0].type = INPUT_KEYBOARD;
in[0].ki.wScan = 0;
in[0].ki.dwFlags = 0;
in[0].ki.time = 0;
in[0].ki.dwExtraInfo = 0;
in[0].ki.wVk = VK_RETURN;

//release enter key
in[1] = in[0];
in[1].ki.dwFlags = KEYEVENTF_KEYUP;

//Hold Shift key and press key 7
in[2].type = INPUT_KEYBOARD;
in[2].ki.wScan = 0;
in[2].ki.dwFlags = 0;
in[2].ki.time = 0;
in[2].ki.dwExtraInfo = 0;
in[2].ki.wVk = VK_SHIFT;

in[3].type = INPUT_KEYBOARD;
in[3].ki.wScan = 0;
in[3].ki.dwFlags = 0;
in[3].ki.time = 0;
in[3].ki.dwExtraInfo = 0;
in[3].ki.wVk = 0x37;

//release key 7
in[4] = in[3];
in[4].ki.dwFlags = KEYEVENTF_KEYUP;

//release key shift
in[5] = in[2];
in[5].ki.dwFlags = KEYEVENTF_KEYUP;

if (SendInput(6, in, sizeof(in)) == 0)
{
std::cout << "Uppps some error in SendInput: " << GetLastError() << std::endl;
}
1
  • I know that my english is not the best, although I have tried very hard to make the question clear and will be voted down immediately. I would like to know what it is to make it better next time. thx Commented Jun 15, 2018 at 11:48

2 Answers 2

7

The size, in bytes, of an INPUT structure. If cbSize is not the size of an INPUT structure, the function fails.

SendInput(6, in, sizeof(INPUT));

Oups...

Sign up to request clarification or add additional context in comments.

Comments

1

The documentation says of cbSize:

The size, in bytes, of an INPUT structure. If cbSize is not the size of an INPUT structure, the function fails.

You are passing sizeof(in), the size of the entire array. Instead pass sizeof(INPUT).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.