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.
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."); } }}