A class that manages a global low level keyboard hook
Пример #1
0
 private static void Initialize()
 {
     mainForm = new MainForm();
     globalHook = new globalKeyboardHook();
     globalHook.HookedKeys.Add(Keys.Home);
     globalHook.KeyDown += OnGlobalKeyDown;
 }
Пример #2
0
        public ProcessControl()
        {
            InitializeComponent();

            keys[0] = new AutoKey(labelHotkey1.Text, (double)numericInterval1.Value);
            keys[1] = new AutoKey(labelHotkey2.Text, (double)numericInterval2.Value);
            keys[2] = new AutoKey(labelHotkey3.Text, (double)numericInterval3.Value);
            keys[3] = new AutoKey(labelHotkey4.Text, (double)numericInterval4.Value);

            gkh = new globalKeyboardHook();
            this.Disposed += ProcessControl_Disposed;

            gkh.HookedKeys.Add(Keys.End);
            gkh.KeyDown += new KeyEventHandler(gkh_KeyDown);

            this.btnHelp.Visible = false;
            // CHANGE
            // gkh.HookedKeys.Clear();
            // gkh.HookedKeys.Add(e.KeyCode);
        }
        private void RegisterKeyHooks()
        {
            gkh = new globalKeyboardHook();

            // Don't let the Garbage Man interfere
            GC.KeepAlive(gkh);

            // Global Hotkey Listener
            gkh.HookedKeys.Add(Keys.MediaPlayPause);
            gkh.HookedKeys.Add(Keys.MediaNextTrack);
            gkh.HookedKeys.Add(Keys.MediaPreviousTrack);
            gkh.HookedKeys.Add(Keys.MediaStop);
            gkh.HookedKeys.Add(Keys.Control);
            gkh.HookedKeys.Add(Keys.ControlKey);
            gkh.HookedKeys.Add(Keys.RControlKey);
            gkh.HookedKeys.Add(Keys.LControlKey);
            gkh.HookedKeys.Add(Keys.Oemplus);
            gkh.HookedKeys.Add(Keys.Add);
            gkh.HookedKeys.Add(Keys.OemMinus);
            gkh.HookedKeys.Add(Keys.Subtract);
            gkh.HookedKeys.Add(Keys.D0);
            gkh.KeyDown += new KeyEventHandler(gkh_KeyDown);
            gkh.KeyUp += new KeyEventHandler(gkh_KeyUp);
        }
Пример #4
0
        /* end http://stackoverflow.com/a/1524047 */

        public Overlay(BotLogic _owner, int _keyOffsetX, int _keyOffsetY, string process)
        {
            InitializeComponent();
            owner = _owner;
            keyOffsetX = _keyOffsetX;
            keyOffsetY = _keyOffsetY - 50;

            overlayFont = new Font(FontFamily.GenericMonospace, 10f);
            creditBrush = new SolidBrush(Color.Aqua);
            initializeOverlayBrushes();

            backgroundBrush = new SolidBrush(Color.Black);

            windowFinder = new WindowFinder();
            windowFinder.SetProcess(process);

            // todo: add hooks programatically
            keyboardHook = new globalKeyboardHook();
            keyboardHook.KeyDown += KeyboardHook_KeyDown;
            keyboardHook.HookedKeys.Add(toggleKey);
            keyboardHook.HookedKeys.Add(toggleVisibleKey);
            keyboardHook.HookedKeys.Add(toggleKeyModeKey);
            keyboardHook.HookedKeys.Add(toggleAutoReadyKey);
            keyboardHook.HookedKeys.Add(dumpKey);
            keyboardHook.hook();

            Byte[] bitmapData = Convert.FromBase64String(CREDIT_IMAGE_B64);
            using (System.IO.MemoryStream streamBitmap = new System.IO.MemoryStream(bitmapData))
            {
                creditImage = (Bitmap)Image.FromStream(streamBitmap);
            }

            creditImageEnabled = getColoredBitmap(creditImage, Color.FromArgb(0, 1, 0));
            creditImageDisabled = getColoredBitmap(creditImage, Color.FromArgb(1, 0, 0));

            this.DoubleBuffered = true;
            //owner.Start();
        }