Sign in to follow this  
Hell4Ge

Ok, so why this code wont work?

Recommended Posts

Hell4Ge    100
[code]
#include <iostream>
#include <Windows.h>

using namespace std;

int main()
{
HWND hwnd = FindWindow("Notepad", NULL);
cout << hwnd << endl;

SendMessage(hwnd, WM_KEYDOWN,0x43, 0); // C Key
SendMessage(hwnd, WM_KEYUP, 0x43, 0);

return 0;
}
[/code]

Tried with VS 2010 and Codeblocks

Share this post


Link to post
Share on other sites
Hell4Ge    100
Keys werent sent to notepad edit field

Ok i know why it wont work
[code]
HWND hwnd = FindWindow("Notepad", NULL);
[/code]

Isnt a "place" to send keys, you must set it with more precision like

[code]
HWND general_hwnd = FindWindow("Notepad", NULL);
HWND edit_hwnd = FindWindowEx(general_hwnd, NULL, "Edit", NULL);
[/code]

Then it will work

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