Exemplo n.º 1
0
 private async Task StartSubprocesses(Data.Types.Keyboard kbd)
 {
     UserSubprocess = new NEHSubprocess(false, kbd.HWID, PIPENAME);
     if (IsStartedAsAdmin)
     {
         AdminSubprocess = new NEHSubprocess(true, kbd.HWID, PIPENAME_ADMIN);
         AdminSubprocess.KeyEventRecieved += new NEHSubprocess.KeyEventRecievedHandler(KeyPressRecieved);
         _ = AdminSubprocess.StartProcess();
     }
     UserSubprocess.KeyEventRecieved += new NEHSubprocess.KeyEventRecievedHandler(KeyPressRecieved);
     await UserSubprocess.StartProcess();
 }
Exemplo n.º 2
0
        private async void EnabledCb_Toggled(object sender, RoutedEventArgs e)
        {
            try
            {
                trayIcon.IsHookEnabled = EnabledCb.IsChecked.Value;
                if (EnabledCb.IsChecked.Value)
                {
                    if (string.IsNullOrEmpty(Variables.Config.TargetKeyboard.HWID))
                    {
                        return;
                    }
                    await NEHSubprocess.KillAllProcesses();

                    UserSubprocess = new NEHSubprocess(false, Variables.Config.TargetKeyboard.HWID, PIPENAME);
                    if (IsStartedAsAdmin)
                    {
                        AdminSubprocess = new NEHSubprocess(true, Variables.Config.TargetKeyboard.HWID, PIPENAME_ADMIN);
                        AdminSubprocess.KeyEventRecieved += new NEHSubprocess.KeyEventRecievedHandler(KeyPressRecieved);
                        _ = AdminSubprocess.StartProcess();
                    }
                    UserSubprocess.KeyEventRecieved += new NEHSubprocess.KeyEventRecievedHandler(KeyPressRecieved);
                    _ = UserSubprocess.StartProcess();
                }
                else
                {
                    if (UserSubprocess != null)
                    {
                        await UserSubprocess.StopProcess();
                    }
                    if (AdminSubprocess != null)
                    {
                        await AdminSubprocess.StopProcess();
                    }
                    UserSubprocess  = null;
                    AdminSubprocess = null;
                }
            }
            catch { }
        }