Jump to content
  • Advertisement
Sign in to follow this  
Hell4Ge

Ok, so why this code wont work?

This topic is 2562 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


#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;
}


Tried with VS 2010 and Codeblocks

Share this post


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

Ok i know why it wont work

HWND hwnd = FindWindow("Notepad", NULL);


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


HWND general_hwnd = FindWindow("Notepad", NULL);
HWND edit_hwnd = FindWindowEx(general_hwnd, NULL, "Edit", NULL);


Then it will work

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!