Advertisement
Guest User

Untitled

a guest
Apr 24th, 2022
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Input;
  4. using NHotkey;
  5. using NHotkey.Wpf;
  6. using WindowsInput;
  7. using WindowsInput.Native;
  8.  
  9. namespace test
  10. {
  11.     public partial class MainWindow : Window
  12.     {
  13.         public MainWindow()
  14.         {
  15.             InitializeComponent();
  16.             ConsoleWindow.ShowConsoleWindow();
  17.             try
  18.             {
  19.                 HotkeyManager.Current.AddOrReplace("Test", Key.G, ModifierKeys.Alt, Test);
  20.             }
  21.             catch (HotkeyAlreadyRegisteredException e)
  22.             {
  23.                 Console.WriteLine(e.Message);
  24.             }
  25.         }
  26.  
  27.         private static void Test(object sender, EventArgs e)
  28.         {
  29.             Console.WriteLine("test");
  30.             var simu = new InputSimulator();
  31.             simu.Keyboard.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_A);
  32.         }
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement