C
C#16mo ago
Shunrai

❔ Cannot simulate keystroke using InputInterceptor

Hello, I am trying to learn how to work with this particular library: https://www.nuget.org/packages/InputInterceptor I have managed to figure out how to create mouse movements, however, I can't figure out how to send keystrokes, I only get the idea on how to swap keyboard keys. Line 35 - 36 is the issue I'm having.
'KeyStroke' does not contain a constructor that takes 2 arguments
'KeyStroke' does not contain a constructor that takes 2 arguments
Any help is welcome. ShuHug
using InputInterceptorNS;
using System;

class Program
{
static void Main(string[] args)
{
if (InitializeDriver())
{
KeyboardHook keyboardHook = new KeyboardHook(KeyboardCallback);
Console.WriteLine("Key simulation started. Press 'V' key to simulate 'H' key. Press 'C' to exit.");

while (true)
{
if (Console.ReadKey(true).Key == ConsoleKey.C)
{
break;
}
}

keyboardHook.Dispose();
}
else
{
InstallDriver();
}

Console.WriteLine("End of program.");
}

static void KeyboardCallback(ref KeyStroke keyStroke)
{
if (keyStroke.Code == KeyCode.V && keyStroke.State == KeyState.Up)
{
InputInterceptor.Send(new[] { new KeyStroke(KeyCode.H, KeyState.Down) });
InputInterceptor.Send(new[] { new KeyStroke(KeyCode.H, KeyState.Up) });
}
}

static bool InitializeDriver()
{
if (InputInterceptor.CheckDriverInstalled())
{
Console.WriteLine("Input interceptor seems to be installed.");
if (InputInterceptor.Initialize())
{
Console.WriteLine("Input interceptor successfully initialized.");
return true;
}
}
Console.WriteLine("Input interceptor initialization failed.");
return false;
}

static void InstallDriver()
{
Console.WriteLine("Input interceptor not installed.");
if (InputInterceptor.CheckAdministratorRights())
{
Console.WriteLine("Installing...");
if (InputInterceptor.InstallDriver())
{
Console.WriteLine("Done! Restart your computer.");
}
else
{
Console.WriteLine("Something... gone... wrong... :(");
}
}
else
{
Console.WriteLine("Restart program with administrator rights so it will be installed.");
}
}
}
using InputInterceptorNS;
using System;

class Program
{
static void Main(string[] args)
{
if (InitializeDriver())
{
KeyboardHook keyboardHook = new KeyboardHook(KeyboardCallback);
Console.WriteLine("Key simulation started. Press 'V' key to simulate 'H' key. Press 'C' to exit.");

while (true)
{
if (Console.ReadKey(true).Key == ConsoleKey.C)
{
break;
}
}

keyboardHook.Dispose();
}
else
{
InstallDriver();
}

Console.WriteLine("End of program.");
}

static void KeyboardCallback(ref KeyStroke keyStroke)
{
if (keyStroke.Code == KeyCode.V && keyStroke.State == KeyState.Up)
{
InputInterceptor.Send(new[] { new KeyStroke(KeyCode.H, KeyState.Down) });
InputInterceptor.Send(new[] { new KeyStroke(KeyCode.H, KeyState.Up) });
}
}

static bool InitializeDriver()
{
if (InputInterceptor.CheckDriverInstalled())
{
Console.WriteLine("Input interceptor seems to be installed.");
if (InputInterceptor.Initialize())
{
Console.WriteLine("Input interceptor successfully initialized.");
return true;
}
}
Console.WriteLine("Input interceptor initialization failed.");
return false;
}

static void InstallDriver()
{
Console.WriteLine("Input interceptor not installed.");
if (InputInterceptor.CheckAdministratorRights())
{
Console.WriteLine("Installing...");
if (InputInterceptor.InstallDriver())
{
Console.WriteLine("Done! Restart your computer.");
}
else
{
Console.WriteLine("Something... gone... wrong... :(");
}
}
else
{
Console.WriteLine("Restart program with administrator rights so it will be installed.");
}
}
}
InputInterceptor 2.2.0
Library for keyboard and mouse input interception and simulation
4 Replies
sibber
sibber16mo ago
why does this install a driver you dont need a driver to simulate input and why do you want to simulate input?
Greg
Greg16mo ago
... intercept CTRL-ALT-DELETE... and do other stuff like peering while at the logon screen.
This interception driver just reeks of bad juju.
sibber
sibber16mo ago
so thats what the driver is for yeah no we cant help with that
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server