Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How to toggle and simulate a key

I am trying to simulate a key button being pressed which is toggleable. So what I am trying to do is in my program, if w is pressed then w will be enabled and kept that way until = is clicked again to toggle it off.

I was doing some research and saw that SendInput() is what is used to do this.

I tried my code like this :

if (GetAsyncKeyState(VK_OEM_PLUS) & 1){
     SendInput(VK_KEY_W) = true;
}
else {
    false;
}

but, it's telling me that my VK_KEY_W key is undefined

if I do SendInput('W') = true; then I get the error:

'SendInput': function does not take 1 arguments

Comments