Jump to content
Sign in to follow this  

C++ SendInput()

Recommended Posts


I'm attempting to learn some more Windows API stuff with c++..

Can anyone tell me why this wont send any keys to the window once it has activated?

#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <iostream>

using namespace std;

int main()
char end;
HWND windowHandle = FindWindow(0, "Untitled - Notepad");
INPUT *key;
if(windowHandle == NULL)
 cout << "not found";

key = new INPUT;
key->type = INPUT_KEYBOARD;
key->ki.wVk = 41;
key->ki.dwFlags = 0;
key->ki.time = 0;
key->ki.wScan = 0;
key->ki.dwExtraInfo = 0;
key->ki.dwExtraInfo = KEYEVENTF_KEYUP;
cout << "key inputted";
cin >> end;
return 0;

Share this post

Link to post
Share on other sites
Richard Robertson

It is doing something. It's sending the key up event. You have to press a key down first, then wait some period of time, then let it up.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.