Jump to content
  • Advertisement
Sign in to follow this  


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

I have a question about sending keys... I have try to make a program that you can type in a text in a dialog box, and then make it write the text into notepad. but the only function I can find is keybd_event in msdn.. but it only takes, VK_KEYS.. how can I do this if I whant to send a string? like this. char string[5] = {"test"}; for(int i=0; i < strlen(string) + 1; i++){ sendKeySomehow(string); } you know what I mean... hope anyone can point me somewere..

Share this post

Link to post
Share on other sites

#include <windows.h>
#include <iostream>
#include <string.h>

using namespace std;

int main(){
HWND notepad_window = FindWindow("Notepad", NULL);
HWND textbox_window = FindWindowEx(notepad_window, NULL, "Edit", NULL);

if (!notepad_window) {
printf("Could not find Notepad\n");
return 1;

string my_string;

cout << "Enter a word to send to Notepad: ";
cin >> my_string;

for (int i = 0; i < my_string.size(); i++)
SendMessage(textbox_window, WM_CHAR, (int)my_string, 0x80000000);
return 0;

If i have understood you corectly this code should help.
You just have to change it so you enter the text in a dialogbox instead of in a console window.

hope it helps

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!