Beispiel #1
0
 static MacroManager()
 {
     Macros       = new Dictionary <uint, MacroEntry>();
     LLKH         = new LowLevelKeyboardHook();
     CurrentMacro = new List <uint>();
     MacroLock    = new object();
     try
     {
         string path = $@"{AppData}\{Path}";
         if (File.Exists(path))
         {
             using (BinaryReader data = new BinaryReader(new MemoryStream(File.ReadAllBytes(path))))
             {
                 MacroEntry entry;
                 int        count = data.ReadInt32();
                 for (int i = 0; i < count; i++)
                 {
                     entry = new MacroEntry();
                     entry.Deserialize(data);
                     Macros.Add(entry.Id, entry);
                     NextFreeId = Math.Max(NextFreeId, entry.Id + 1);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Program.MainForm.Notify(e.ToString(), "Loading Error", ToolTipIcon.Error);
     }
     LLKH.KeyboardAction += OnKeyboardAction;
     LLKH.Start();
 }
Beispiel #2
0
    public async Task DefaultTest()
    {
        using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
        var cancellationToken = cancellationTokenSource.Token;

        using var hook = new LowLevelKeyboardHook().WithEventLogging();

        hook.Start();

        await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
    }
Beispiel #3
0
    public async Task LeftRightGranularityTest()
    {
        using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
        var cancellationToken = cancellationTokenSource.Token;

        using var hook = new LowLevelKeyboardHook
              {
                  IsLeftRightGranularity = true,
              }.WithEventLogging();

        hook.Start();

        await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
    }
Beispiel #4
0
    public async Task HandlingTest()
    {
        using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
        var cancellationToken = cancellationTokenSource.Token;

        using var hook = new LowLevelKeyboardHook
              {
                  Handling = true,
              }.WithEventLogging();
        hook.Up   += (_, args) => args.IsHandled = true;
        hook.Down += (_, args) => args.IsHandled = true;

        hook.Start();

        await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
    }