Sign in to follow this  

Ok, so why this code wont work?

This topic is 2344 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[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
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

This topic is 2344 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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