AttachThreadInput(currentProccess,dfProccess,TRUE);//The two threads have to have attached input in order to change the keyboard state, which is needed to set the shift state
while((cChar=*lpszString++))// loops through chars
{
shortvk=VkKeyScan(cChar);// keycode of char
if(useShift||(vk>>8)&1)// char is capital, so need to hold down shift
{
//shift down
INPUTinput[4]={0};
input[0].type=INPUT_KEYBOARD;
input[0].ki.wVk=VK_SHIFT;
input[1].type=INPUT_KEYBOARD;
input[1].ki.wVk=vk;
input[2].type=INPUT_KEYBOARD;
input[2].ki.wVk=vk;
input[2].ki.dwFlags=KEYEVENTF_KEYUP;
// shift up
input[3].type=INPUT_KEYBOARD;
input[3].ki.wVk=VK_SHIFT;
input[3].ki.dwFlags=KEYEVENTF_KEYUP;
SendInput(4,input,sizeof(input[0]));
BYTEkeybstate[256]={0};
BYTEkeybstateOrig[256]={0};
GetKeyboardState((LPBYTE)&keybstateOrig);
GetKeyboardState((LPBYTE)&keybstate);
keybstate[VK_SHIFT]|=0x80;//Set shift state to on in variable
SetKeyboardState((LPBYTE)&keybstate);//set the current state to the variable