Click to See Complete Forum and Search --> : Sending combo keys to a window.


mrcr
March 25th, 2006, 04:44 AM
Hey, I'm attempting to write a program that will open a file, search it for specific text, and then copy that text and paste it into another window.

I am okay with the file i/o part. I can open the file, find the text and parse it to another file. I'm also okay with sending keyboard input to the window i need open. I use:

if(hwnd)
{
if(IsIconic(hwnd))
OpenIcon(hwnd);

SetForegroundWindow(hwnd);
SetFocus(hwnd);
}

To get the right window and use SendInput to pass keyboard input to the window. The problem is I can't figure out how to send key combinations like Shift+Control instead of just Shift or just Control. In this case I need to use Control+V to paste what I copied from the file.

Is that the best way though, to copy it from the file and then use control v with sendinput to paste it to the window? First time trying go from reading a file and outputting it to an active window instead of to another file.

golanshahar
March 25th, 2006, 05:10 AM
The problem is I can't figure out how to send key combinations like Shift+Control instead of just Shift or just Control. In this case I need to use Control+V to paste what I copied from the file.



Its simple you should use ::SendInput() now suppose you want to send Ctrl+Shift+a.



SendInput() Ctrl down
SendInput() Shift down
SendInput() 'A' down
SendInput() 'A' up
SendInput() Shift up
SendInput() Ctrl up


Look in this FAQ also: How can I emulate keyboard events in an application? (http://www.codeguru.com/forum/showthread.php?t=377393)

Cheers

mrcr
March 25th, 2006, 07:30 PM
Thanks.. new to SendInput and had things a little out of order. Releasing the control key too early. Should have caught that myself :/