views:

45

answers:

0

What should I use for automating DirectX applications from C# code? I'd like to send key and mouse messages to a DirectX game, from within a C# application. I've tried the pInvoke solutions to no avail, having code like

INPUT[] InputData = new INPUT[1];

InputData[0].type = (UInt32)InputType.KEYBOARD;
InputData[0].ki.wScan = (ushort)0x041e;
InputData[0].ki.dwFlags = (uint)KeyboardFlag.SCANCODE;
InputData[0].ki.time = 0;
InputData[0].ki.dwExtraInfo = 0;
SendInput(1, ref InputData[0], Marshal.SizeOf(InputData[0]));




INPUT[] InputData1 = new INPUT[1];

InputData1[0].type = (UInt32)InputType.KEYBOARD;
InputData1[0].ki.wScan = (ushort)0x041e;
InputData1[0].ki.dwFlags = (uint)KeyboardFlag.KEYUP | (uint)KeyboardFlag.SCANCODE;
InputData1[0].ki.time = 0;
InputData1[0].ki.dwExtraInfo = 0;
SendInput(1, ref InputData1[0], Marshal.SizeOf(InputData1[0]));

run well with standard desktop apps, yet silently fail to perform any action within the DirectX app. Please, advise me what else should I try; I've discovered and tested with the same bad results a couple of automation libraries usable from C# - they all perform well within GDI+ apps, fail to achieve results in DirectX apps. Is there any automation framework specifically targeted at DirectX apps, that I could link to in my C# code?