How can I simulate a button press in .NET?
I can do it with AutoHotKey with ease:
#Persistent
SetTimer,PressTheKey,1000
Return
PressTheKey:
Send, {F5}
Return
Any application will know that the button was pressed (just like it was pressed by me). I tried doing the same with:
[DllImport("user32.dll", SetLastError = true)]
public static extern uint SendInput(uint nInputs, INPUT[] pInputs, int cbSize);
or:
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, int dwExtraInfo);
or using Windows Input Simulator (https://inputsimulator.codeplex.com/):
inputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_H)
They all worked in Notepad or some other apps, but they never worked in my full screen game. Any idea how I can achieve it? I would like a solution which simulates a click globally on the system level.