DetourIt

 SDK 

 

SendKey
 
Sends a keyboard key to the specified window. 
 
Syntax:
 
void SendKey(
   HWND hWnd,
   BYTE key,
);
 
 
Parameters:
 
 
hWnd
 
            type: HWND
 
            The handle to the control.
 
 
key
 
            type: BYTE (char)
 
            The key to send to the window.
 
 
'a', 'b', 'c', 'A', 'B', 'C' etc 
 
VK_RETURN    Enter
 
VK_TAB          TAB key
 
VK_BACK        Backspace
 
VK_DELETE     Delete
 
 
 
Return Value:
 
No return value:
 
 
 
Example:
 
 
#include "detourit.h"

 
void main()
{
 
    //We use FindWindow (a win32 api) to find a Notepad window. 
    //You must have an untitled notepad window open in order for this to work.
    //We leave the classname NULL as we are only interested in the window title.
    //The L before the "Untitled - Notepad" is only for Unicode projects.
 
    HWND hWndParent = FindWindow(NULL, L"Untitled - Notepad");
 
    //Now we need to find the edit-box part of the notepad window.
    //Notice that we use FindWindowEx() here. This is because it is capable of searching
    //for child windows. This time we search for classname instead of window title.
 
    HWND hWnd = FindWindowEx(hWndParent, NULL, L"Edit", NULL);
 
    //This is the character array we are going to send to Notepad.
    BYTE keys[15] = "Hello DetourIt";
 
    for (int i = 0; i < 15; i ++)
    {
        //Each iteration will send a new key to the Notepad window.
        SendKey(hWnd, keys[i]);
    }
 
    //An exclamation mark for added effect.
    SendKey(hWnd, '!');
}