This class monitors all mouse activities and provides appropriate events.
상속: BaseHookListener
예제 #1
0
        public HIDListener(GUI o)
        {
            Debug.WriteLine("HIDListen instansiated ");
            owner = o;
            Thread thread = Thread.CurrentThread;

            owner.ServiceDebugConsole("HIDListener started on Thread : " + thread.Name + thread.ManagedThreadId);

            m_KeyboardHookManager = new KeyboardHookListener(new GlobalHooker());
            m_KeyboardHookManager.Enabled = true;

            m_MouseHookManager = new MouseHookListener(new GlobalHooker());
            m_MouseHookManager.Enabled = true;

            Hooker hook;
            hook = new GlobalHooker();
            m_KeyboardHookManager.Replace(hook);
            //m_KeyboardHookManager.Enabled = true;
            m_MouseHookManager.Replace(hook);

            m_MouseHookManager.MouseMove += HookManager_MouseMove;
            m_MouseHookManager.MouseClickExt += HookManager_MouseClick;
            m_MouseHookManager.MouseUp += HookManager_MouseUp;
            m_MouseHookManager.MouseDown += HookManager_MouseDown;
            m_MouseHookManager.MouseDoubleClick += HookManager_MouseDoubleClick;
            m_MouseHookManager.MouseWheel += HookManager_MouseWheel;
               // m_MouseHookManager.MouseDownExt += HookManager_Supress;
            m_KeyboardHookManager.KeyDown += HookManager_KeyDown;
            m_KeyboardHookManager.KeyUp += HookManager_KeyUp;
            m_KeyboardHookManager.KeyPress += HookManager_KeyPress;

            owner.ServiceDebugConsole("HIDListener start Completed : " + thread.Name);
        }
        public Main()
        {
            try
            {
                InitializeComponent();
                ProcessFile();
                WriteFile();
                MessageBox.Show("Done!");
                return;
                _mMouseHookManager = new MouseHookListener(new GlobalHooker()) {Enabled = true};
                _mMouseHookManager.MouseUp += mMouseHookManager_MouseUp;

                ReadKeyFile(Properties.Settings.Default.KeyPath);

                IDuplexTypedMessagesFactory aSenderFactory = new DuplexTypedMessagesFactory();
                _mySender = aSenderFactory.CreateDuplexTypedMessageSender<AppQA, MyResponse>();

                IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();
                IDuplexOutputChannel anOutputChannel =
                    aMessaging.CreateDuplexOutputChannel("tcp://" + Properties.Settings.Default.IpAddress + ":8060/");

                // Attach the input channel and start to listen to messages.
                _mySender.AttachDuplexOutputChannel(anOutputChannel);
            }
            catch (Exception exception)
            {
                WriteAnswer(Properties.Settings.Default.AnswerPath, exception.Message);
            }
        }
예제 #3
0
        public Recorder(Test test)
        {
            this.test = test;

            ScreenshotsEnabled = true;
            CurrentRecorderState = RecorderState.Stopped;

            globalHooker = new GlobalHooker();
            globalHooker2 = new GlobalHooker();

            keyboardHookListener = new KeyboardHookListener(globalHooker2);
            mouseHookListener = new MouseHookListener(globalHooker);

            keyboardHookListener.KeyDown += KeyboardHookListenerOnKeyDown;
            keyboardHookListener.KeyUp += KeyboardHookListenerOnKeyUp;

            mouseHookListener.MouseDown += MouseHookListenerOnMouseDown;
            mouseHookListener.MouseUp += MouseHookListenerOnMouseUp;

            mouseHookListener.Enabled = false;
            mouseHookListener.Enabled = false;

            keyboardHelper = new KeyboardHelper();

            currentInputType = InputType.None;

            InsertPosition = -1;
        }
예제 #4
0
        static void Main(string[] args)
        {
            var globalHooker = new MKB.WinApi.GlobalHooker();

            using (var mouseOverlay = new MouseOverlay())
                using (var kbOverlay = new KeyboardOverlay())
                    using (var msListener = new MKB.MouseHookListener(globalHooker))
                        using (var kbListener = new MKB.KeyboardHookListener(globalHooker))
                        {
                            msListener.MouseDown  += (sender, eventArgs) => mouseOverlay.MouseDown(eventArgs);
                            msListener.MouseMove  += (sender, eventArgs) => mouseOverlay.MouseMove(eventArgs);
                            msListener.MouseUp    += (sender, eventArgs) => mouseOverlay.MouseUp(eventArgs);
                            msListener.MouseWheel += (sender, eventArgs) => mouseOverlay.MouseWheel(eventArgs);

                            kbListener.KeyDown += (sender, eventArgs) => kbOverlay.KeyDown(eventArgs);

                            msListener.Start();
                            kbListener.Start();

                            Application.Run();

                            msListener.Stop();
                            kbListener.Stop();
                        }
        }
예제 #5
0
 private Session()
 {
     // create the keyboard and mouse hooks, for the app only
     Hooker hook = new AppHooker();
     _mouseListener = new MouseHookListener(hook);
     _keyboardListener = new KeyboardHookListener(hook);
     this.InSession = false;
 }
예제 #6
0
        static void Main(string[] args)
        {
            var globalHooker = new GlobalHooker();
            var mouseListenerHooker = new MouseHookListener(globalHooker);

            var mouseDownRecorder = new MouseDownRecorder(mouseListenerHooker);
            mouseDownRecorder.Register(OnActionOccured);
            System.Console.ReadLine();
        }
예제 #7
0
        public DeviceController(LauncherController lc)
        {
            Launcher = lc;

            //Keyboard & Mouse Hoocks
            m_KeyboardHookManager = new KeyboardHookListener(new GlobalHooker());
            m_KeyboardHookManager.Enabled = false;
            m_MouseHookManager = new MouseHookListener(new GlobalHooker());
            m_MouseHookManager.Enabled = false;
        }
예제 #8
0
 public WindowsActivityMonitor()
 {
     mouseListener = new MouseHookListener(new GlobalHooker());
     mouseListener.Enabled = true;
     mouseListener.MouseMove += onMouseMove;
     mouseListener.MouseClick += onMouseClick;
     mouseListener.MouseWheel += onMouseClick;
     kbListener = new KeyboardHookListener(new GlobalHooker());
     kbListener.Enabled = true;
     kbListener.KeyDown += onKeyPress;
 }
예제 #9
0
        public MainWindow()
        {
            InitializeComponent();
            var globalHooker = new GlobalHooker();
            var mouseListenerHooker = new MouseHookListener(globalHooker);
            var mouseDownListener = new MouseDownActionListener(mouseListenerHooker);

            var mouseDownRecorder = new MouseDownActionPublisher();
            mouseDownRecorder.Register(mouseDownListener);
            mouseDownRecorder.UserActionPublished += mouseDownRecorder_UserActionPublished;
            mouseListenerHooker.Start();
        }
예제 #10
0
        public MouseButtonDownUpSource(
            Enums.MouseButtons triggerButton,
            IObservable<Timestamped<PointAndKeyValue?>> pointAndKeyValueSource)
        {
            this.triggerButton = (System.Windows.Forms.MouseButtons)triggerButton; //Cast to the Windows.Forms.MouseButtons enum
            this.pointAndKeyValueSource = pointAndKeyValueSource;

            mouseHookListener = new MouseHookListener(new GlobalHooker())
            {
                Enabled = true
            };
        }
예제 #11
0
        public MouseButtonDownUpSource(
            MouseButtons triggerButton,
            IObservable<Timestamped<PointAndKeyValue?>> pointAndKeyValueSource)
        {
            this.triggerButton = triggerButton;
            this.pointAndKeyValueSource = pointAndKeyValueSource;

            mouseHookListener = new MouseHookListener(new GlobalHooker())
            {
                Enabled = true
            };
        }
        public MoonPdfPanelInputHandler(MoonPdfPanel source)
        {
            this.source = source;

            this.source.PreviewKeyDown += source_PreviewKeyDown;
            this.source.PreviewMouseWheel += source_PreviewMouseWheel;
            this.source.PreviewMouseLeftButtonDown += source_PreviewMouseLeftButtonDown;

            this.mouseHookListener = new MouseHookListener(new GlobalHooker());
            this.mouseHookListener.Enabled = false;
            this.mouseHookListener.MouseMove += mouseHookListener_MouseMove;
            this.mouseHookListener.MouseUp += mouseHookListener_MouseUp;
        }
        /// <summary>
        /// register mouse & keyboard events
        /// </summary>
        public ScreenshotChangedTracker()
        {
            // Register Hooks for Mouse
            _mouseListener = new MouseHookListener(new GlobalHooker());
            _mouseListener.Enabled = true;
            _mouseListener.MouseWheel += MouseListener_MouseScrolling;
            _mouseListener.MouseClick += MouseListener_MouseClicking;

            // Register Hooks for Keyboard
            _keyboardListener = new KeyboardHookListener(new GlobalHooker());
            _keyboardListener.Enabled = true;
            _keyboardListener.KeyDown += KeyboardListener_KeyDown;
        }
예제 #14
0
        public Form1(List <Flask> importedFlasks, int _globalPercentage, float _flaskAlpha, int _xAdjustment, float _xResolution, float _yResolution, bool _showWC)
        {
            showWC = _showWC;

            xResolution      = _xResolution;
            yResolution      = _yResolution;
            xAdjustment      = _xAdjustment;
            flaskAlpha       = _flaskAlpha;
            globalPercentage = _globalPercentage;
            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle;
            Flasks = importedFlasks;
            Application.AddMessageFilter(this);
            this.handle = Handle;
            int initialStyle = GetWindowLong(this.Handle, -20);

            SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);
            SetWindowPos(this.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
            OnResize(null);
            keyboardListener           = new KeyboardHookListener(new GlobalHooker());
            keyboardListener.Enabled   = true;
            keyboardListener.KeyPress += KeyboardListener_KeyDown;
            mouseListener              = new MouseHookListener(new GlobalHooker());
            mouseListener.Enabled      = true;
            mouseListener.MouseDown   += MouseListener_KeyDown;
            InitializeComponent();
            foreach (Flask f in Flasks)
            {
                f.useDuration = 0;
            }
            locMods.Add(new double[2] {
                0.1734375, 0.97407407
            });
            locMods.Add(new double[2] {
                0.197395833, 0.97407407
            });
            locMods.Add(new double[2] {
                0.2213541666, 0.97407407
            });
            locMods.Add(new double[2] {
                0.2453125, 0.97407407
            });
            locMods.Add(new double[2] {
                0.269270833, 0.97407407
            });
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += new DoWorkEventHandler(worker_DoWork);
            worker.RunWorkerAsync();
        }
예제 #15
0
        public GBGNodeCreateModify(GBGMain parent, GenericNode internalNode, Boolean createMode)
        {
            InitializeComponent();

            this.parent = parent;
            inCreateMode = createMode;
            _internalNode = internalNode;

            m_KeyboardHookManager = new KeyboardHookListener(new GlobalHooker());
            m_KeyboardHookManager.Enabled = true;

            m_MouseHookManager = new MouseHookListener(new GlobalHooker());
            m_MouseHookManager.Enabled = true;

            m_MouseHookManager.MouseClick += HookManager_MouseClick;
            m_KeyboardHookManager.KeyPress += HookManager_KeyPress;
        }
예제 #16
0
        public LauncherForm()
        {
            InitializeComponent();

            myWinApi = new WinApi();
            myAuthForm = new AuthenticationForm(this);
            myWaitForm = new WaitForm();
            myBrowserForm = new BrowserForm();

            //Keyboard & Mouse
            m_KeyboardHookManager = new KeyboardHookListener(new GlobalHooker());
            m_KeyboardHookManager.Enabled = false;
            m_MouseHookManager = new MouseHookListener(new GlobalHooker());
            m_MouseHookManager.Enabled = false;

            isRunspaceActive = false;
            isTunnelActive  = false;
            isPoolActive = false;

            isLauncherVisible = true;
            isBrowserFormVisible = false;
            isWaitFromVisible = false;
            isAuthFormVisible = false;

            isLauncherEnabled = true;
            isKioskEnabled = false;
            isScreenEnabled = true;
            isKeyboardEnabled = true;
            isMouseEnabled = true;
            isSpeakerEnabled = true;
            isWebcamEnabled = false;
            isHeadsetEnabled = false;
            isUsbEnabled = false;

            preventClose = true;
            clientCount = 0;

            timerStart.Interval = 100;
            timerShutdown.Interval = 100;

            customCommands = new string[12, 2];

            comboBoxAuthType.SelectedIndex = 0;
        }
예제 #17
0
        public HIDListener()
            : base()
        {
            Hooker hook = new GlobalHooker();
            //Keyboard Hook
            m_KeyboardHookManager = new KeyboardHookListener(new GlobalHooker());
            m_KeyboardHookManager.Replace(hook);
            m_KeyboardHookManager.Enabled = true;
            //Mouse Hook
            m_MouseHookManager = new MouseHookListener(new GlobalHooker());
            m_MouseHookManager.Enabled = true;
            //Set up Keyboard deligate methods.
            m_KeyboardHookManager.KeyDown += HookManager_KeyDown;
            m_KeyboardHookManager.KeyUp += HookManager_KeyUp;

            m_MouseHookManager.MouseMove += HookManager_MouseMove;
            m_MouseHookManager.MouseUp += HookManager_MouseUp;
            m_MouseHookManager.MouseDown += HookManager_MouseDown;
        }
예제 #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow"/> class. 
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            Visible = false;

            _capturer = new Capturer();
            
            // TODO: Make this functionality better & work well for "folder path changed during runtime"...
            System.IO.Directory.CreateDirectory(Settings.Default.SaveFolder);

            _lastShotTaken = 0;
            
            _listenerKeyboard = new KeyboardHookListener(new GlobalHooker());
            _listenerMouse = new MouseHookListener(new GlobalHooker());

            _listenerKeyboard.Enabled = true;
            _listenerMouse.Enabled = true;

            // Start listening to Mouse- and KeyDown.
            _listenerKeyboard.KeyDown += ListenerKeyboardKeyDown;
            _listenerMouse.MouseDown += ListenerMouseMouseDown;
            _listenerMouse.MouseUp += ListenerMouseMouseUp;
        }
예제 #19
0
파일: App.cs 프로젝트: p3lim/Lackey
        private void InitializeComponent()
        {
            keyboardHook = new KeyboardHookListener(new GlobalHooker());
            keyboardHook.Enabled = true;
            keyboardHook.KeyDown += keyboardHook_KeyDown;
            keyboardHook.KeyUp += keyboardHook_KeyUp;

            mouseHook = new MouseHookListener(new GlobalHooker());
            mouseHook.Enabled = true;
            mouseHook.MouseWheel += mouseHook_MouseWheel;
            mouseHook.MouseDown += mouseHook_MouseDown;
            mouseHook.MouseUp += mouseHook_MouseUp;

            simulator = new InputSimulator();

            trayMenu = new ContextMenu();
            trayMenu.MenuItems.Add("Run on startup", ToggleStartup);
            trayMenu.MenuItems.Add("Exit", OnExit);

            trayIcon = new NotifyIcon();
            trayIcon.Text = "Lackey";
            trayIcon.Icon = Resources.Icon;
            trayIcon.ContextMenu = trayMenu;
            trayIcon.Visible = true;
        }
예제 #20
0
 public MouseListenerAdapter(MouseHookListener source)
 {
     _source = source;
     _source.MouseMoveExt += OnMouseMove;
 }
예제 #21
0
 public MouseDownActionListener(MouseHookListener mouseHookListener)
 {
     mouseHookListener.MouseDown += MouseHookListenerMouseDown;
 }
예제 #22
0
파일: MainForm.cs 프로젝트: 07box/07box
 protected void InitializeMouseMoveHook()
 {
     try
     {
         mouseMoveListener = new MouseHookListener(globalHooker);
         mouseMoveListener.MouseMoveExt += MouseListener_MouseMoveExt;
         mouseMoveListener.Enabled = true;
     }
     catch (Exception e)
     {
         System.Diagnostics.Trace.WriteLine(string.Format("Couldn't initialize mouse move hook: {0}", e.Message));
         Application.Exit();
     }
 }
예제 #23
0
파일: MainForm.cs 프로젝트: 07box/07box
 protected void DisposeListener(MouseHookListener listener)
 {
     try {
         listener.Enabled = false;
     } catch (Exception ex) {}
 }
예제 #24
0
 public ClickReplay() {
     mouseListener = new MouseHookListener(new GlobalHooker());
     keyListener = new KeyboardHookListener(new GlobalHooker());
     Count = 0;
 }
예제 #25
0
        //private Mouseho

        // Subroutine for activating the hook
        public void Activar()
        {
            // Note: for an application hook, use the AppHooker class instead
            m_mouseListener = new MouseHookListener(new GlobalHooker());
            m_keyboardListener = new KeyboardHookListener(new GlobalHooker());
            // The listener is not enabled by default
            m_mouseListener.Enabled = true;
            m_keyboardListener.Enabled = true;
            // Set the event handler
            // recommended to use the Extended handlers, which allow input suppression among other additional information
           // m_mouseListener.MouseDownExt += MouseListener_MouseDownExt;
            m_mouseListener.MouseMoveExt += MouseListener_MouseMove;
            m_keyboardListener.KeyDown += KeyBoardListener_KeyDown;
        }
        private void ExecuteSelectImageCommand()
        {
            testItemController.MinimizeTestItemEditorWindow();

            Window window = new Window();
            window.Height = SystemParameters.VirtualScreenHeight;
            window.Width = SystemParameters.VirtualScreenWidth;
            bool doPicture = false;

            Canvas canvas = new Canvas();
            canvas.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(100, 100,100,100));
            Rectangle rectangle = new Rectangle();
            rectangle.StrokeThickness = 2;
            rectangle.Stroke = Brushes.Red;
            rectangle.Height = 0;
            rectangle.Width = 0;
            Canvas.SetTop(rectangle, 0);
            Canvas.SetLeft(rectangle, 0);
            System.Drawing.Point point = new System.Drawing.Point();

            GlobalHooker hooker = new GlobalHooker();
            MouseHookListener listener = new MouseHookListener(hooker);

            bool isMouseDown = false;
            bool isComplete = false;
            System.Drawing.Point topLeft = new System.Drawing.Point();
            System.Drawing.Point bottomRight = new System.Drawing.Point();

            listener.MouseDown += (o, args) =>
            {
                isMouseDown = true;
                topLeft = System.Windows.Forms.Cursor.Position;
            };

            listener.MouseUp += (o, args) =>
            {

                isMouseDown = false;
                bottomRight = System.Windows.Forms.Cursor.Position;
                isComplete = true;
            };

            listener.Enabled = true;

            Task task = new Task(() =>
            {
                listener.Enabled = true;

                while (!isComplete)
                {
                    Thread.Sleep(250);
                    while (isMouseDown)
                    {
                        point = System.Windows.Forms.Cursor.Position;

                        Rect bounds = new Rect(new Point(topLeft.X, topLeft.Y), new Point(point.X, point.Y));

                        Thread.Sleep(100);
                        Application.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            rectangle.Width = bounds.Width;
                            rectangle.Height = bounds.Height;
                            Canvas.SetTop(rectangle, bounds.Y);
                            Canvas.SetLeft(rectangle, bounds.X);
                        }));
                    }
                }

            });

            canvas.Children.Add(rectangle);
            window.Left = 0;
            window.Top = 0;

            window.Content = canvas;
            window.WindowStyle = new WindowStyle();
            window.ShowInTaskbar = false;
            window.AllowsTransparency = true;

            Bitmap screenshot = new Bitmap(1,1);

            BitmapImage bitmapImage = new BitmapImage();

            window.Topmost = true;

            Task waitTask = new Task(() =>
            {
                Thread.Sleep(3000);
                Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    using (MemoryStream memory = new MemoryStream())
                    {
                        screenshot = Camera.Capture(0, ScreenCaptureMode.Screen);
                        screenshot.Save(memory, ImageFormat.Png);
                        memory.Position = 0;

                        bitmapImage.BeginInit();
                        bitmapImage.StreamSource = memory;
                        bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
                        bitmapImage.EndInit();
                    }

                    window.Background = new ImageBrush(bitmapImage);

                    window.Show();
                }));

            });

            task.ContinueWith(t =>
            {
                System.Drawing.Rectangle systemRect = new System.Drawing.Rectangle(topLeft.X, topLeft.Y,
                    bottomRight.X-topLeft.X, bottomRight.Y-topLeft.Y);

                Bitmap tempBitmap = new Bitmap(systemRect.Width, systemRect.Height);

                using (Graphics g = Graphics.FromImage(tempBitmap))
                {
                    g.DrawImage(screenshot, new System.Drawing.Rectangle(0, 0, tempBitmap.Width, tempBitmap.Height),
                        systemRect, GraphicsUnit.Pixel);
                }

                Image = tempBitmap;

                TestItem testItem = testItemController.CurrentTestItem;
                OperationParameter operationParameter = testItem.Operation.GetParameterNamed("Image");
                operationParameter.Value = Image;

                Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    window.Close();
                    Thread.Sleep(500);
                    testItemController.RestoreTestItemEditorWindow();
                    Thread.Sleep(500);
                    testItemController.RestoreTestItemEditorWindow();
                }));

            });

            waitTask.Start();
            waitTask.ContinueWith(t => task.Start());

            window.Closed += (o, args) =>
            {
                doPicture = false;
                task.Dispose();
            };
        }
예제 #27
0
        private void tGiveMessage(Message message)
        {
            switch (message.message)
            {

                case messageEnum.StartGettingKeyboard:
                    {
                        gettingKeyboard = true;
                        m_KeyboardHookManager = new KeyboardHookListener(new GlobalHooker());
                        m_KeyboardHookManager.Replace(hook);
                        m_KeyboardHookManager.KeyDown += HookManager_KeyDown;
                        m_KeyboardHookManager.KeyUp += HookManager_KeyUp;
                        m_KeyboardHookManager.Enabled = true;
                        break;
                    }
                case messageEnum.StopGettingKeyboard:
                    {
                        gettingKeyboard = false;
                        break;
                    }
                case messageEnum.StartGettingMouse:
                    {
                        m_MouseHookManager = new MouseHookListener(new GlobalHooker());
                        m_MouseHookManager.Enabled = true;
                        //Set up Keyboard deligate methods.

                        m_MouseHookManager.MouseMove += HookManager_MouseMove;
                        m_MouseHookManager.MouseUp += HookManager_MouseUp;
                        m_MouseHookManager.MouseDown += HookManager_MouseDown;
                        gettingMouse = true;
                        break;
                    }
                case messageEnum.StopGettingMouse:
                    {
                        gettingMouse = false;
                        break;
                    }
            }

             /*   MessageBox.Show("HID Getter REC : " + message.ToString()
               + "\ngettingKeyboard: " + gettingKeyboard.ToString()
            + "\ngettingMouse: " + gettingMouse.ToString());*/
        }