'Send keystrokes to a DirectX Program

I am trying to send keystrokes to DirectX program through sendInput and from what I understand I need to make use of Scan Codes, I've written this code but it just won't transfer through to the program. (C#)

Input[] mag = new Input[2];
                mag[0].type = 1;
                mag[0].u.ki.wVk = 0;
                mag[0].u.ki.wScan = 0x03;
                mag[0].u.ki.dwFlags = 0x0004 | 0x0008;
                for (int j = 1; j <= 400;  j += 20)
                {
                    SendInput(1, mag, Marshal.SizeOf(typeof(Input)));
                    Thread.Sleep(20);
                }
                mag[0].u.ki.dwFlags = 0x0002 | 0x0008 | 0x0004;
                SendInput(1, mag, Marshal.SizeOf(typeof(Input)));

using SendInput, SendKeys, different wrappers, nothing I do seems to help



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source