Note that there are some explanatory texts on larger screens.

plurals
  1. POsending simultaneous keyboard events with SendInput on windows in C++
    primarykey
    data
    text
    <p>I want to simulate keyboard presses in C++ using <b>SendInput</b>, while single buttons work, trying to send keys simultaneously (shortcuts) doesn't work.</p> <p>I tried everything, but nothing works, if I send <b>VK_LWIN</b> alone it shows up, but couldn't combine keys simultaneously.</p> <p><b>here's my code:</b></p> <pre><code>#include &lt;windows.h&gt; #include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; void setInput(INPUT * inp,uint index, WORD keycode,BOOL kUp); void showRun(); int main(void) { showRun(); return 0; } void setInput(INPUT * inp,uint index, WORD keycode,BOOL kUp) { inp[index].type = INPUT_KEYBOARD; inp[index].ki.wVk = keycode; inp[index].ki.wScan = MapVirtualKey(keycode, 0); inp[index].ki.time = 0; inp[index].ki.dwExtraInfo = 0; if (kUp == 1) { inp[index].ki.dwFlags = KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY; }else { inp[index].ki.dwFlags = 0 | KEYEVENTF_EXTENDEDKEY; } } //this doesn't do anything void showRun() { INPUT *inp = (INPUT*) malloc(sizeof(INPUT) * 4); memset(inp,0,sizeof(INPUT)); setInput(inp,0,VK_LWIN,0); setInput(inp,1,VK_RBUTTON,0); setInput(inp,2,VK_RBUTTON,1); setInput(inp,3,VK_LWIN,1); SendInput(4,inp,sizeof(INPUT)); free(inp); } </code></pre> <p><b>while this works fine:</b></p> <pre><code>void showStart() { INPUT *inp = (INPUT*) malloc(sizeof(INPUT) * 2); memset(inp,0,sizeof(INPUT)); setInput(inp,0,VK_LWIN,0); setInput(inp,1,VK_LWIN,1); SendInput(2,inp,sizeof(INPUT)); free(inp); } </code></pre> <p>Thanks in advance for any tip.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload