Hey everyone ive bought the hardware and will now solve some questions:
You always need a 360 Controller I bought this one:
http://www.amazon.de/gp/product/B004JU0 ... ge_o01_s00
Then I tried to send keyboard events to the gimx window but as there is no documentation about it. I found out that with c# you have to sen Keystrokes by using the SendInput Api also note that you have to send ScanCodes instead of Virtual Keys like so:
So for example to press "s"
Code: Select all
[DllImport("user32.dll")]
static extern bool SetForegroundWindow(IntPtr hWnd);
private void button1_Click(object sender, EventArgs e)
{
Process p = Process.GetProcessById(6740); // My PID of gimx Process
IntPtr test = p.MainWindowHandle;
SetForegroundWindow(test);
SendSKey(50);
}
public static void SendSKey(int HoldTime)
{
INPUT INPUT1 = new INPUT();
INPUT1.type = (int)InputType.INPUT_KEYBOARD;
//INPUT1.ki.wVk = (short)key;
INPUT1.ki.wScan = 31; // 31 = s
INPUT1.ki.dwFlags = 8;
INPUT1.ki.dwExtraInfo = GetMessageExtraInfo();
SendInput(1, new INPUT[] { INPUT1 }, Marshal.SizeOf(INPUT1));
Thread.Sleep(HoldTime);
INPUT INPUT2 = new INPUT();
INPUT2.type = (int)InputType.INPUT_KEYBOARD;
INPUT2.ki.wScan = 31;
INPUT2.ki.dwFlags = 10;
INPUT2.ki.dwExtraInfo = GetMessageExtraInfo();
SendInput(1, new INPUT[] { INPUT2 }, Marshal.SizeOf(INPUT2));
}
[StructLayout(LayoutKind.Explicit)]
public struct INPUT
{
[FieldOffset(4)]
public HARDWAREINPUT hi;
[FieldOffset(4)]
public KEYBDINPUT ki;
[FieldOffset(4)]
public MOUSEINPUT mi;
[FieldOffset(0)]
public int type;
}
[StructLayout(LayoutKind.Sequential)]
public struct MOUSEINPUT
{
public int dx;
public int dy;
public int mouseData;
public int dwFlags;
public int time;
public IntPtr dwExtraInfo;
}
[StructLayout(LayoutKind.Sequential)]
public struct KEYBDINPUT
{
public short wVk;
public short wScan;
public int dwFlags;
public int time;
public IntPtr dwExtraInfo;
}
[StructLayout(LayoutKind.Sequential)]
public struct HARDWAREINPUT
{
public int uMsg;
public short wParamL;
public short wParamH;
}
[Flags]
public enum InputType
{
INPUT_MOUSE = 0,
INPUT_KEYBOARD = 1,
INPUT_HARDWARE = 2
}
[Flags]
public enum MOUSEEVENTF
{
MOVE = 0x0001, /* mouse move */
LEFTDOWN = 0x0002, /* left button down */
LEFTUP = 0x0004, /* left button up */
RIGHTDOWN = 0x0008, /* right button down */
RIGHTUP = 0x0010, /* right button up */
MIDDLEDOWN = 0x0020, /* middle button down */
MIDDLEUP = 0x0040, /* middle button up */
XDOWN = 0x0080, /* x button down */
XUP = 0x0100, /* x button down */
WHEEL = 0x0800, /* wheel button rolled */
MOVE_NOCOALESCE = 0x2000, /* do not coalesce mouse moves */
VIRTUALDESK = 0x4000, /* map to entire virtual desktop */
ABSOLUTE = 0x8000 /* absolute move */
}
[Flags]
public enum KEYEVENTF
{
KEYDOWN = 0,
EXTENDEDKEY = 0x0001,
KEYUP = 0x0002,
UNICODE = 0x0004,
SCANCODE = 0x0008,
}
Thnks