Hello, i just made this program to push the '5' button repeatedly when I hold the 'f12' button and this works just fine but i have a question! When I run this program while I'm playing super mario bros this program does not work!
I use the 5 button to jump and when i press the 'f12' button he doesn't jumps! I already tried to change the time of the function "Sleep();" to 1000,5000,100,500 but nothing worked.

So my question is: This kind of program doesn't work with other programs? Why?

#define WINVER 0x0500
#include <windows.h>
#include <stdio.h>

INPUT input[2];

       // Simulate a key press
       input[0].type = INPUT_KEYBOARD;
       input[0].ki.wVk = VK_NUMPAD5;
       input[0].ki.wScan = 0;
       input[0].ki.dwFlags = 0;
       input[0].ki.time = 0;
       input[0].ki.dwExtraInfo = 0;

       // Simulate a key release
       input[1].type = INPUT_KEYBOARD;
       input[1].ki.wVk = VK_NUMPAD5;
       input[1].ki.wScan = 0;
       input[1].ki.dwFlags = KEYEVENTF_KEYUP ;
       input[1].ki.time = 0;
       input[1].ki.dwExtraInfo = 0;

      if( GetAsyncKeyState(VK_F12))
         SendInput(2, input, sizeof(INPUT));      
3 Years
Discussion Span
Last Post by Ancient Dragon

It doesn't work with other programs because the other programs are not in the same address space as the one you posted. What you want to do is called injecting, here are a few google links for you to consider.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.