views:

211

answers:

1

i have been having a hard time to find anything that is usefull but i found someone asked how to do that,(http://stackoverflow.com/questions/2113950/how-to-send-keystrokes-to-a-window)

if used the code and i can set notepad's text but i want to send keys but sets the text, i want to send keys like keybd_event i have been using it but i want to only have it send to one program.

keybd_event('a', NULL, NULL, NULL);  
keybd_event('a', NULL, KEYEVENTF_KEYUP, NULL); 

how could i do that?

A: 

Sounds like you're trying to make a window have the focus before sending your keys. Look at FindWindow and SetForegroundWindow.

Something like this should work:

SetForegroundWindow(FindWindow(0,"Untitled - Notepad"));
keybd_event(....);

If instead you're talking about changing a window's text directly, look at GetWindow to navigate the window tree and SendMessage with a WM_SETTEXT parameter.

Blindy
err :| ok i'll give it a try
blood