Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

Delays with Windows SendInput API: Input to editor, IE or notepad is delayed

$
0
0

Hi there,

We have developed a virtual keyboard (vk) and use Windows API to display it. Later on, the vk is used to input the keys to the internet explorer. 

The problem is the keys are taking long to display at times and sometimes, there is a delay and the key(s) will only pop up once subsequent keys are pressed. What is causing this behavior? I used native C++ to use the API and here is the function that calls the SendInput API:

void CallSendInput(int vKey, int nKbdState)
{
INPUT inpt = {INPUT_KEYBOARD, {0}};


    if (pfKeyPress)
return;

    if (nKbdState & 0x01) {inpt.ki.wVk=VK_SHIFT; SendInput(1, &inpt, sizeof(INPUT));}
    if (nKbdState & 0x02) {inpt.ki.wVk=VK_CONTROL; SendInput(1, &inpt, sizeof(INPUT));}
if (nKbdState & 0x03) {inpt.ki.wVk=VK_CANCEL; SendInput(1, &inpt, sizeof(INPUT));}
    if (nKbdState & 0x04) {inpt.ki.wVk=VK_MENU; SendInput(1, &inpt, sizeof(INPUT));}

inpt.ki.wScan = MapVirtualKey(vKey, MAPVK_VK_TO_VSC);
inpt.ki.time = 0;
inpt.ki.dwExtraInfo = 0;
inpt.ki.dwFlags = 0; 

inpt.ki.wVk = vKey;

SendInput(1, &inpt, sizeof(INPUT));
    inpt.ki.dwFlags=KEYEVENTF_KEYUP;

    SendInput(1, &inpt, sizeof(INPUT));

    bKEYUPForced = true;
    if (nKbdState & 0x01) {inpt.ki.wVk=VK_SHIFT; SendInput(1, &inpt, sizeof(INPUT));}
    if (nKbdState & 0x02) {inpt.ki.wVk=VK_CONTROL; SendInput(1, &inpt, sizeof(INPUT));}
if (nKbdState & 0x03) {inpt.ki.wVk=VK_CANCEL; SendInput(1, &inpt, sizeof(INPUT));}
    if (nKbdState & 0x04) {inpt.ki.wVk=VK_MENU; SendInput(1, &inpt, sizeof(INPUT));}

}

I will appreciate the solution to this.


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>