• Advertisement
Sign in to follow this  

SendKeys.

This topic is 4817 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
Advertisement

#include <windows.h>
#include <iostream>
#include <string.h>
#include<conio.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");
system("Pause");
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