SendKeys.

Started by
3 comments, last by X5-Programmer 19 years, 2 months ago
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..
-[ thx ]-
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
use VkKeyScanEx in user32.dll to convert to a virtual key
thanks for your help guys!.
-[ thx ]-
Just one more thing.. Cant I just send the keys and not have the hWnd for the window?.

Just send the keys not to a special place or something.
-[ thx ]-

This topic is closed to new replies.

Advertisement