I'm trying to create a winform C# application, which will send keystrokes to a program, acting like a macro application (sending keystrokes). I am using Windows Input Simulator. https://inputsimulator.codeplex.com/
The problem is that it can only send keystrokes to a program with admin right, if the application I created also runs with admin rights. The only way I've found to run a .application file is by using CMD, which is a headache, any other ways to do it?
Second it does not seem to work with all programs. I have trouble trying to send keystrokes to Avid - Pro Tools. Maybe there is another method of sending keystrokes?
I can easily achieve macros with my Logitech mouse, why can't I do that with programming? Am I missing something?
Here's to focus an application code:
protected override CreateParams CreateParams
{
get
{
CreateParams param = base.CreateParams;
param.ExStyle |= 0x08000000;
return param;
}
}
And a sample send code:
private void audioTrack_Click(object sender, EventArgs e)
{
InputSimulator.SimulateModifiedKeyStroke(
new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT },
new[] { VirtualKeyCode.VK_N });
InputSimulator.SimulateKeyDown(VirtualKeyCode.RETURN);
}
Seems like SendKeys.Send is the way to go! Don't know why I bothered to use Windows Input Simulator library... With SendKeys.Send it works perfectly, no need for admin rights and much less code.