how do i send keystrokes to only one program?
i have been having a hard time to find anything tha开发者_开发知识库t is usefull but i found someone asked how to do that,(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?
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.
精彩评论