예제 #1
0
 /// <summary>
 /// Writes the action data.
 /// </summary>
 /// <param name="mouseEvents">The mouse events.</param>
 /// <param name="myMouse">My mouse.</param>
 /// <param name="delayTime">The delay time.</param>
 public void WriteData(string mouseEvents, MSLLHOOKSTRUCT myMouse, int delayTime)
 {
     XElement newAction = new XElement("Action", new XAttribute("Type", "MouseAct"), new XAttribute("DelayTime", delayTime.ToString()),
      new XElement("Position", myMouse.pt.ToString()),
      new XElement("MouseEvent", mouseEvents));
     xRoot.Add(newAction);
 }
예제 #2
0
        /// <summary>
        /// Mouse Down event for Middle mouse button
        /// </summary>
        /// <param name="mouseStruct">The mouse parameters</param>
        public void OnMiddleMousedown(MSLLHOOKSTRUCT mouseStruct)
        {
            OnMouse(mouseStruct);

            if (!onScreen)
            {
                return;
            }

            foreach (var guide in Canvas.Children.OfType <Guide>())
            {
                if (guide.OnLeftMouseDown(mousePoint))
                {
                    Canvas.Children.Remove(guide);
                    return;
                }
            }

            ResetAllGuidesActive();

            if (App.Ctrl)
            {
                var guide = new CircleGuide(this, mousePoint);
                Canvas.Children.Add(guide);
            }
            else
            {
                var guide = new LineGuide(this, mousePoint.Y);
                Canvas.Children.Add(guide);
            }
        }
예제 #3
0
        private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            //IntPtr activeWindowHandle = GetForegroundWindow();
            //Process curProcess = Process.GetCurrentProcess();
            //if (activeWindowHandle == curProcess.MainWindowHandle)
            //{

            if (nCode >= 0 &&
                MouseMessages.WM_RBUTTONDOWN == (MouseMessages)wParam)
            {
                return(new IntPtr(1));
            }
            if (nCode >= 0 &&
                MouseMessages.WM_RBUTTONUP == (MouseMessages)wParam)
            {
                MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                //Console.WriteLine(hookStruct.pt.x + ", " + hookStruct.pt.y);
                RemoteControlButton rcb = RemoteControlButton.Details;
                OMLApplication.Current.CatchMoreInfo();
                SendMoreInfo();
                //if (this.ButtonPressed != null && rcb != RemoteControlButton.Unknown)
                //    this.ButtonPressed(this, new RemoteControlEventArgs(rcb, InputDevice.Mouse));
                return(new IntPtr(1));
            }
            //}
            return(CallNextHookEx(_hookID, nCode, wParam, lParam));
        }
예제 #4
0
        /// <summary>
        /// Mouse Wheel response
        /// </summary>
        /// <param name="mouseStruct">The mouse parameters</param>
        public void OnMouseWheel(MSLLHOOKSTRUCT mouseStruct)
        {
            OnMouse(mouseStruct);

            if (!onScreen)
            {
                return;
            }
            if (!App.Shift)
            {
                return;
            }

            var delta = 5;

            if (App.Ctrl)
            {
                delta = 10;
            }
            if (App.Alt)
            {
                delta = 1;
            }
            foreach (var guide in Canvas.Children.OfType <Guide>())
            {
                guide.OnMouseWheel(mousePoint, mouseStruct.mouseData, delta);
            }
        }
예제 #5
0
            /// <summary>
            /// マウスのフックプロシージャ
            /// </summary>
            /// <param name="nCode">フックコード</param>
            /// <param name="msg">フックプロシージャに渡す値</param>
            /// <param name="s">フックプロシージャに渡す値</param>
            /// <returns>フックチェーン内の次のフックプロシージャの戻り値</returns>
            private System.IntPtr MouseHookProcedure(
                int nCode,
                uint msg,
                ref MSLLHOOKSTRUCT s
                )
            {
                try
                {
                    if (0 <= nCode)
                    {
                        switch (msg)
                        {
                        case 0x0202:            // WM_LBUTTONUP
                            if (MouseLeftUpStop)
                            {
                                StopWindowSelection();
                                MouseLeftButtonUp?.Invoke(this, new MouseLeftButtonUpEventArgs());
                            }
                            break;

                        case 0x0200:          // WM_MOUSEMOVE
                            FrameWindowProcessing();
                            break;
                        }
                    }
                }
                catch
                {
                }

                return(NativeMethods.CallNextHookEx(Handle, nCode, msg, ref s));
            }
예제 #6
0
 private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
 {
     if (nCode >= 0 && MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam)
     {
         MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
         LeftMouseDownAction();
     } else 
     if (nCode >= 0 && MouseMessages.WM_RBUTTONDOWN == (MouseMessages)wParam)
     {
         MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
         RightMouseAction();
     } else 
     if (nCode >= 0 && MouseMessages.WM_MOUSEMOVE == (MouseMessages)wParam)
     {
         MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
         MoveMouseAction(hookStruct.pt);
     }
     else
     if (nCode >= 0 && MouseMessages.WM_LBUTTONUP == (MouseMessages)wParam)
     {
         MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
         LeftMouseUpAction();
     }
     return CallNextHookEx(_hookID, nCode, wParam, lParam);
 }
예제 #7
0
        public void mouseMsgReceiver(Int32 wParam, IntPtr lParam)
        {
            MSLLHOOKSTRUCT msg = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));

            msgManager?.Invoke(wParam, msg);
            timerInterrupt(wParam, msg);
        }
예제 #8
0
    public static IntPtr MouseHookCallback(int nCode, IntPtr wParam, IntPtr lParam)
    {
        if (nCode >= 0)
        {
            MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));

            switch ((MouseMessages)wParam)
            {
            case MouseMessages.WM_LBUTTONDOWN:
                KeyEvent(new KeypressEventArgs()
                {
                    Key   = Keys.LButton,
                    State = KeyState.Down
                });
                break;

            case MouseMessages.WM_LBUTTONUP:
                KeyEvent(new KeypressEventArgs()
                {
                    Key   = Keys.LButton,
                    State = KeyState.Up
                });
                break;
            }
        }


        return(CallNextHookEx(_hookID_Mouse, nCode, wParam, lParam));
    }
예제 #9
0
 private bool IsWMParamMatchesStartingButtonUp(IntPtr wParam, IntPtr lParam)
 {
     if ((int)wParam == WMessageStartingButtonUp)
     {
         if ((int)wParam == WM_XBUTTONUP)
         {
             MSLLHOOKSTRUCT mouseHookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
             if (mouseHookStruct.mouseData >> 16 == 1) // X1(戻るボタン)
             {
                 Debug.WriteLine("Starting Button Up: Mouse XButton1 (戻るボタン)");
                 if (startingButton == MouseButton.XButton1)
                 {
                     return(true);
                 }
             }
             else  // X2(進むボタン)
             {
                 Debug.WriteLine("Starting Button Up: Mouse XButton2 (進むボタン)");
                 if (startingButton == MouseButton.XButton2)
                 {
                     return(true);
                 }
             }
         }
         else
         {
             Debug.WriteLine("Starting Button Up: " + WMessageStartingButtonUp.ToString());
             return(true);
         }
     }
     return(false);
 }
 int MouseEvents(int code, IntPtr wParam, IntPtr lParam)
 {
     //Console.WriteLine("Called");
     if (code < 0)
     {
         return(CallNextHookEx(_hook, code, wParam, lParam));
     }
     if (code == this.HC_ACTION)
     {
         // Left button pressed somewhere
         if (wParam.ToInt32() == (uint)WM.WM_RBUTTONDOWN)
         {
             MSLLHOOKSTRUCT ms = new MSLLHOOKSTRUCT();
             ms = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
             IntPtr win   = WindowFromPoint(ms.pt);
             string title = GetWindowTextRaw(win);
             if (RButtonClicked != null)
             {
                 RButtonClicked(this, new SysMouseEventInfo {
                     WindowTitle = title
                 });
             }
         }
     }
     return(CallNextHookEx(_hook, code, wParam, lParam));
 }
예제 #11
0
        private string GetClickStroke(IntPtr wParam, IntPtr lParam)
        {
            string         clickStroke     = "";
            MSLLHOOKSTRUCT mouseHookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));

            switch ((int)wParam)
            {
            case WM_LBUTTONDOWN:
                clickStroke = "[L]";
                break;

            case WM_RBUTTONDOWN:
                clickStroke = "[R]";
                break;

            case WM_MBUTTONDOWN:
                clickStroke = "[M]";
                break;

            case WM_XBUTTONDOWN:
                if (mouseHookStruct.mouseData >> 16 == 1)     // X1(戻るボタン)
                {
                    clickStroke = "[X1]";
                }
                else      // X2(進むボタン)
                {
                    clickStroke = "[X2]";
                }
                break;
            }

            return(clickStroke);
        }
예제 #12
0
        private void TryHoldClick(IntPtr wParam, IntPtr lParam)
        {
            MSLLHOOKSTRUCT mouseHookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
            string         strEnd;

            switch ((int)wParam)
            {
            case WM_LBUTTONUP:
                strEnd = "[L]";
                break;

            case WM_RBUTTONUP:
                strEnd = "[R]";
                break;

            case WM_MBUTTONUP:
                strEnd = "[M]";
                break;

            case WM_XBUTTONUP:
                if (mouseHookStruct.mouseData >> 16 == 1)     // X1(戻るボタン)
                {
                    strEnd = "[X1]";
                }
                else      // X2(進むボタン)
                {
                    strEnd = "[X2]";
                }
                break;

            case WM_MOUSEWHEEL:
                if ((short)((mouseHookStruct.mouseData >> 16) & 0xffff) > 0)      // Wheel Up
                {
                    if (!stroke.EndsWith("[WU]"))
                    {
                        stroke = stroke + "[WU]";
                        StrokeChanged?.Invoke(this, new EventArgs());
                    }
                    strEnd = "[WU]";
                }
                else      // Wheel Down
                {
                    if (!stroke.EndsWith("[WD]"))
                    {
                        stroke = stroke + "[WD]";
                        StrokeChanged?.Invoke(this, new EventArgs());
                    }
                    strEnd = "[WD]";
                }
                break;

            default:
                return;
            }

            if (stroke.EndsWith(strEnd))
            {
                HoldClick?.Invoke(this, new EventArgs());
            }
        }
예제 #13
0
            private static IntPtr MouseHookForLeftClickUpEvent(int nCode, IntPtr wParam, IntPtr lParam)

            {
                if (nCode >= 0)
                {
                    var message = (MouseMessages)wParam;

                    if (message == MouseMessages.WM_LBUTTONDOWN)
                    {
                        if (stopOnClick)
                        {
                            UnhookWindowsHookEx(_mouseHookID);
                        }

                        MSLLHOOKSTRUCT       hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                        System.Windows.Point point      = new System.Windows.Point(hookStruct.pt.x, hookStruct.pt.y);
                        MouseEvent?.Invoke(null, new MouseCoordinateEventArgs()
                        {
                            MouseCoordinates = point
                        });
                    }
                }

                return(CallNextHookEx(_mouseHookID, nCode, wParam, lParam));
            }
예제 #14
0
        /// <summary>
        /// Mouse Move event
        /// </summary>
        /// <param name="mouseStruct">The mouse parameters</param>
        public void OnMouseMove(MSLLHOOKSTRUCT mouseStruct)
        {
            onScreen = PointInScreen(mouseStruct.pt);

#if UPDATE_BLOCK
            if (updateWatch.ElapsedMilliseconds <= UpdateSleep)
            {
                return;
            }
#endif

            OnMouse(mouseStruct);

            if (!onScreen)
            {
                return;
            }
            if (Canvas.Children.Count <= 0)
            {
                return;
            }

#if UPDATE_BLOCK
            updateWatch.Restart();
#endif

            foreach (var guide in Canvas.Children.OfType <Guide>())
            {
                if (guide.OnMouseMove(mousePoint))
                {
                    break;
                }
            }
        }
예제 #15
0
        /// <summary>
        /// Disable ot enabled Mouse Buttons from SebClient configuration
        ///</summary>
        private static bool DisableMouseButton(int nCode, IntPtr wp, IntPtr lp)
        {
            MSLLHOOKSTRUCT MouseButtonInfo = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lp, typeof(MSLLHOOKSTRUCT));

            if (!(Boolean)SEBClientInfo.getSebSetting(SEBSettings.KeyEnableRightMouse)[SEBSettings.KeyEnableRightMouse])
            {
                //Console.WriteLine(String.Format("NCode: {0}, wp; {1} {2}",nCode,wp,(MouseMessages)wp));
                if (nCode >= 0 &&
                    (MouseMessages.WM_RBUTTONDOWN == (MouseMessages)wp ||
                     MouseMessages.WM_RBUTTONUP == (MouseMessages)wp))
                {
                    return(true);
                }
            }
            if (
                !(Boolean)
                SEBClientInfo.getSebSetting(SEBSettings.KeyEnableAltMouseWheel)[SEBSettings.KeyEnableAltMouseWheel])
            {
                KBDLLHOOKSTRUCT KeyInfo = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lp, typeof(KBDLLHOOKSTRUCT));
                if ((Control.ModifierKeys & Keys.Alt) != 0 && KeyInfo.flags < 0)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #16
0
 public void Process(
     ref MouseInput input,
     WindowsMessages msg,
     MSLLHOOKSTRUCT msllhookstruct)
 {
     input.State = GetState(msg);
 }
예제 #17
0
        private int LowLevelMouseHook_Callback(int code, IntPtr wParam, IntPtr lParam, ref bool callNext)
        {
            if (code == HC_ACTION)
            {
                MSLLHOOKSTRUCT llh = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));

                bool handled = false;
                fireMouseEvents(wParam, llh.pt, llh.mouseData, llh.flags, llh.time, llh.dwExtraInfo, ref handled);

                if (MouseIntercepted != null)
                {
                    MouseIntercepted((int)wParam, llh.pt, llh.mouseData, llh.flags, llh.time, llh.dwExtraInfo, ref handled);
                }
                if (MessageIntercepted != null)
                {
                    MessageIntercepted(new LowLevelMouseMessage((int)wParam, llh.pt, llh.mouseData, llh.flags, llh.time, llh.dwExtraInfo), ref handled);
                }
                if (handled)
                {
                    callNext = false;
                    return(1);
                }
            }
            return(0);
        }
예제 #18
0
        /*
         * HookCallback: Handle mouse events when they happen
         * @param int nCode: Must be positive
         *        IntPtr wParam: The mouse button that was clicked
         *        IntPtr lParam: Not used
         * @return IntPtr: Next hook
         */
        private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            // Convert the hook to a structure
            MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));

            // If the nCode is positive and the button clicked is left, then run MouseClicked.
            if (nCode >= 0 && MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam)
            {
                MouseClicked(null, new EventArgs());
            }
            else
            {
                // If the nCode is positive and the button clicked is right, then run MouseRightClicked.
                if (nCode >= 0 && MouseMessages.WM_RBUTTONDOWN == (MouseMessages)wParam)
                {
                    MouseRightClicked(null, new EventArgs());
                }
                else
                {
                    // Otherwise another mouse activitiy occurred
                    MouseAction(null, new EventArgs());
                } // end if right click
            }     // end if left click

            return(CallNextHookEx(_hookID, nCode, wParam, lParam));
        } // end HookCallback
예제 #19
0
 private static IntPtr HookCallback(
     int nCode, IntPtr wParam, IntPtr lParam)
 {
     if (nCode >= 0 && MouseMessages.WM_MOUSEMOVE == (MouseMessages)wParam)
     {
         MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
         MouseMove(null, new EventArgs());
     }
     if (nCode >= 0 && MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam)
     {
         MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
         LeftClick(null, new EventArgs());
     }
     if (nCode >= 0 && MouseMessages.WM_RBUTTONDOWN == (MouseMessages)wParam)
     {
         MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
         ReightClick(null, new EventArgs());
     }
     if (nCode >= 0 && MouseMessages.WM_MOUSEWHEEL == (MouseMessages)wParam)
     {
         MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
         MouseWheel(null, new EventArgs());
     }
     return(CallNextHookEx(_hookID, nCode, wParam, lParam));
 }
예제 #20
0
        private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0 && MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam)
            {
                MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                inCapture = true;
                filtro    = new FiltroDeMensagens();
                filtro.iniciarAquisicao(hookStruct.pt.x, hookStruct.pt.y);
                System.Drawing.Icon ic = new Icon("img\\operando.ico");
                nf.Icon = ic;
            }

            if (nCode >= 0 && MouseMessages.WM_MOUSEMOVE == (MouseMessages)wParam && inCapture)
            {
                MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                filtro.verificarMovimento(hookStruct.pt.x, hookStruct.pt.y);
            }

            if (nCode >= 0 && MouseMessages.WM_LBUTTONUP == (MouseMessages)wParam && inCapture)
            {
                MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                inCapture = false;
                filtro.finalizarAquisicao(); //hookStruct.pt.x, hookStruct.pt.y);
                System.Drawing.Icon ic = new Icon("img\\play.ico");
                nf.Icon = ic;
            }
            return(CallNextHookEx(_hookID, nCode, wParam, lParam));
        }
        //mouse hook
        private static IntPtr HookCallbackM(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0 && wParam != (IntPtr)MouseMessages.WM_MOUSEMOVE && wParam != (IntPtr)MouseMessages.WM_MOUSEWHEEL)
            {
                checkCurrentWindow();

                MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                string         coords     = "(x" + hookStruct.pt.x + "y" + hookStruct.pt.y + ")";

                //Console.WriteLine(coords);

                //get the mouse
                if ((IntPtr)MouseMessages.WM_LBUTTONDOWN == wParam)
                {
                    writeToFile("[Left Button]");
                }
                else if ((IntPtr)MouseMessages.WM_LBUTTONUP == wParam)
                {
                    //nothing
                }
                else if ((IntPtr)MouseMessages.WM_RBUTTONDOWN == wParam)
                {
                    writeToFile("[Right Button]");
                }
                else if ((IntPtr)MouseMessages.WM_RBUTTONUP == wParam)
                {
                    //nothing
                }
                else
                {
                    writeToFile(coords);
                }
            }
            return(User32.CallNextHookEx(_hookMID, nCode, wParam, lParam));
        }
예제 #22
0
        void OnMouse(MSLLHOOKSTRUCT mouseStruct)
        {
#if DEBUG_OVERLAY
#if DEBUG_CROSS
            horiz.location = mousePoint.Y;
            vert.location  = mousePoint.X;
#endif
            ScreenIndexLabel.Content     = $"Screen {screenIndex}";
            ScreenIndexLabel.Foreground  = screenColor;
            ScreenSizeLabel.Content      = $"Screen size {Width} x {Height}";
            ScreenOffsetLabel.Content    = $"Screen offset {Left} x {Top}";
            WindowSizeLabel.Content      = $"Window Size {Canvas.Width:f1} x {Canvas.Height:f1}";
            ResolutionScaleLabel.Content = $"Resolution Scale {ResolutionScaleX:f6} x {ResolutionScaleY:f6}";
            RawMouseLabel.Content        = $"Raw mouse {mouseStruct.pt.x:f1} x {mouseStruct.pt.y:f1}";
            ScreenMouseLabel.Content     = $"Screen mouse {mousePoint.X:f1} x {mousePoint.Y:f1}";
            OnScreenLabel.Content        = onScreen ? "On Screen" : "Off Screen";
            OnScreenLabel.Foreground     = onScreen ? Brushes.ForestGreen : Brushes.Red;
            var guidesList  = Canvas.Children.OfType <Guide>().ToArray();
            var guidesCount = guidesList.Length;
            GuidesLabel.Content = $"Guides ({guidesCount}):";

            const double lineHeight = 18;
            DebugBox.Height = debugBoxStartHeight + guidesCount * lineHeight;
            GuidesBox.Text  = string.Empty;
            if (Guide.ActiveGuide != null)
            {
                GuidesBox.Text += $"Active Guide {Guide.ActiveGuide}\n";
            }
            foreach (var guide in guidesList)
            {
                GuidesBox.Text += $"{guide}\n";
            }
#endif
        }
예제 #23
0
            public static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
            {
                if (nCode >= 0)
                {
                    MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));

                    if ((wParam.ToInt32() & 0xF) == 1)
                    {
                        MouseFlag = 1;
                    }
                    else if ((wParam.ToInt32() & 0xF) == 2)
                    {
                        MouseFlag = 2;
                    }
                    else if ((wParam.ToInt32() & 0xF) == 4)
                    {
                        MouseFlag = 4;
                    }
                    else if ((wParam.ToInt32() & 0xF) == 5)
                    {
                        MouseFlag = 5;
                    }
                    else if ((wParam.ToInt32() & 0xF) == 0)
                    {
                        MouseFlag = 0;
                    }
                    if (CanSend)
                    {
                        MainWindow.udp.SendMessageTo(UDP.Mouse + MouseFlag + UDP.Breaker + (mousePos.X - Location.X) + UDP.Breaker + (mousePos.Y - Location.Y), remoteIP);
                    }
                    //        System.Diagnostics.Debug.WriteLine(Convert.ToString(wParam.ToInt32(), 16) + " " + hookStruct.flags + " " + mousePos.X + " " + mousePos.Y);
                }

                return(CallNextHookEx(_hookID, nCode, wParam, lParam));
            }
예제 #24
0
        private static bool HandleMouseInput(MSLLHOOKSTRUCT strct, MouseMessages mm)
        {
            if (strct.flags != 0 || !Program.isToggled || !(a.minecraft != IntPtr.Zero))
            {
                return(true);
            }
            switch (mm)
            {
            case MouseMessages.WM_LBUTTONDOWN:
                isLeftDown = true;
                PostMessage(a.minecraft, 513u, 0, 0);
                break;

            case MouseMessages.WM_LBUTTONUP:
                isLeftDown = false;
                PostMessage(a.minecraft, 514u, 0, 0);
                break;

            case MouseMessages.WM_RBUTTONDOWN:
                PostMessage(a.minecraft, 516u, 0, 0);
                break;

            case MouseMessages.WM_RBUTTONUP:
                PostMessage(a.minecraft, 517u, 0, 0);
                break;

            default:
                return(true);
            }
            return(false);
        }
예제 #25
0
        private static void MouseButtonDown(MSLLHOOKSTRUCT m)
        {
            if (HotkeyState.HasFlag(TriggerHotkeys) || TriggerHotkeys == default(state))
            {
                candidateWindow = GetWindowDetailsFromPoint(m.pt);
                if (candidateWindow.IsPartOfWindowsUI)
                {
                    Console.WriteLine("Candidate Window is shell window -- NO!");
                    candidateWindow = null;
                    return;
                }
                if (DropZone.Settings.OnlyTriggerOnTitleBarClick && m.pt.y > candidateWindow.rect.Top + candidateWindow.TitleBarHeight)
                {
                    Console.WriteLine("Click detected, but not in title bar constraints");
                    candidateWindow = null;
                    return;
                }

                HotkeyState.Add(state.active);
                new System.Threading.Tasks.Task(() =>
                {
                    mhook.MouseMove += Mhook_MouseMove;
                    renderer.ActivateSector(LayoutCollection.ActiveLayout.GetActiveZoneFromPoint(m.pt.x, m.pt.y));

                    renderer.RenderZone(ScreenInfo.GetDisplays().MaxWidth, ScreenInfo.GetDisplays().MaxHeight);
                }).Start();
#if DEBUG
                printState(m);
#endif
            }
        }
예제 #26
0
        private static IntPtr myHookMouseProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0 && MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam)
            {
                MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                inCapture = true;
                startPOS  = hookStruct.pt;

                System.Console.WriteLine("myHookMouseProc start capture " + nCode + "--" + startPOS.x.ToString() + "," + startPOS.y.ToString());
            }
            else if (nCode >= 0 && MouseMessages.WM_LBUTTONUP == (MouseMessages)wParam)
            {
                MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                inCapture = false;
                endPOS    = hookStruct.pt;

                System.Console.WriteLine("myHookMouseProc end capture " + nCode + "--" + endPOS.x.ToString() + "," + endPOS.y.ToString());

                DoCapture();
                StopCapture();
            }
            else if (nCode >= 0 && MouseMessages.WM_MOUSEMOVE == (MouseMessages)wParam)
            {
                MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                curPOS = hookStruct.pt;
                myPreviewForm.Invalidate();
            }

            return(CallNextHookEx(hook, 1, wParam, lParam));
        }
예제 #27
0
 private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
 {
     if (nCode >= 0)
     {
         if (MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam)
         {
             MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
             MouseLeftButtonDownAction(hookStruct, new EventArgs());
         }
         //switch ((MouseMessages)wParam)
         //{
         //    case MouseMessages.WM_LBUTTONDOWN:
         //        MouseLeftButtonDownAction(hookStruct, new EventArgs());
         //        break;
         //    case MouseMessages.WM_LBUTTONUP:
         //        MouseLeftButtonUpAction(hookStruct, new EventArgs());
         //        break;
         //    case MouseMessages.WM_RBUTTONDOWN:
         //        MouseRightButtonDownAction(hookStruct, new EventArgs());
         //        break;
         //    case MouseMessages.WM_RBUTTONUP:
         //        MouseRightButtonUpAction(hookStruct, new EventArgs());
         //        break;
         //    case MouseMessages.WM_MOUSEMOVE:
         //        MouseMoveAction(hookStruct, new EventArgs());
         //        break;
         //    case MouseMessages.WM_MOUSEWHEEL:
         //        MouseWheelAction(hookStruct, new EventArgs());
         //        break;
         //    default: break;
         //}
     }
     return(CallNextHookEx(_hookID, nCode, wParam, lParam));
 }
예제 #28
0
        private static void sendCallback(IntPtr lParam, String s)
        {
            MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));

            hookStruct.MouseAction = s;
            MouseAction(hookStruct, new EventArgs());
        }
예제 #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="code"></param>
        /// <param name="wParam"></param>
        /// <param name="lParam"></param>
        /// <returns></returns>
        public Int32 MyMouseCallBack(Int32 code, WindowsMessages wParam, MSLLHOOKSTRUCT lParam)
        {
            if (code < 0)
            {
                return(NativeMethod.CallNextHookEx(IntPtr.Zero, code, wParam, lParam));
            }
            switch (wParam)
            {
            case WindowsMessages.WM_MOUSEMOVE:
                if (MouseMove == null)
                {
                    break;
                }
                MouseMove(lParam.pt.X, lParam.pt.Y);
                break;

            case WindowsMessages.WM_LBUTTONDOWN:
                if (MouseLeftDown == null)
                {
                    break;
                }
                MouseLeftDown(lParam.pt.X, lParam.pt.Y);
                break;
            }

            // キーの処理を次に回して完了。
            return(NativeMethod.CallNextHookEx(IntPtr.Zero, code, wParam, lParam));
        }
예제 #30
0
 private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
 {
     if (nCode >= 0 &&
         MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam)
     {
         MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
         if (!ignoreflag && installed)
         {
             if (Util.GetRuneScapeHandle() != IntPtr.Zero)
             {
                 //int x = hookStruct.pt.x;
                 //int y = hookStruct.pt.y;
                 PinloggerHelpers.pinImages.Add(Util.CaptureRuneScapeScreen());
                 Console.WriteLine(PinloggerHelpers.pinImages.Count);
                 if (PinloggerHelpers.pinImages.Count >= 4)
                 {
                     PinloggerHelpers.FinalizePins();
                     //Thread t = new Thread(new ThreadStart(PinloggerHelpers.FinalizePins));
                     //t.SetApartmentState(ApartmentState.STA);
                     //t.Start();
                 }
             }
             else
             {
                 Uninstall();
             }
         }
     }
     return(CallNextHookEx(_hookID, nCode, wParam, lParam));
 }
예제 #31
0
        private IntPtr MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                MSLLHOOKSTRUCT mouseHookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                if (wParam.ToInt32() == WM_LBUTTONDOWN)
                {
                    if (MouseDown != null)
                    {
                        MouseDown.Invoke(null, new System.Drawing.Point(mouseHookStruct.pt.x, mouseHookStruct.pt.y));
                    }

                    return(new IntPtr(-1));
                }

                if (wParam.ToInt32() == WM_MOUSEWHEEL)
                {
                    if (MouseWheel != null)
                    {
                        MouseDevice mouseDev = InputManager.Current.PrimaryMouseDevice;
                        MouseWheel.Invoke(null, new MouseWheelEventArgs(mouseDev, Environment.TickCount, (int)mouseHookStruct.mouseData >> 16));
                    }
                }
            }

            return(CallNextHookEx(_mouseHookHandle, nCode, wParam, lParam));
        }
예제 #32
0
        protected override int OnProc(int code, IntPtr wParam, IntPtr lParam)
        {
            MouseButtons none;
            MSLLHOOKSTRUCT structure = new MSLLHOOKSTRUCT();
            Marshal.PtrToStructure(lParam, structure);
            MouseEventArgs e = null;
            switch (wParam.ToInt32())
            {
                case 0x200:
                    none = MouseButtons.None;
                    if (!this.LeftDown)
                    {
                        if (this.RightDown)
                        {
                            none = MouseButtons.Right;
                        }
                        break;
                    }
                    none = MouseButtons.Left;
                    break;

                case 0x201:
                    this.LeftDown = true;
                    e = new MouseEventArgs(MouseButtons.Left, 0, structure.pt.X, structure.pt.Y, 0);
                    this.OnButtonDown(e);
                    goto Label_0158;

                case 0x202:
                    this.LeftDown = false;
                    e = new MouseEventArgs(MouseButtons.Left, 0, structure.pt.X, structure.pt.Y, 0);
                    this.OnButtonUp(e);
                    goto Label_0158;

                case 0x204:
                    this.RightDown = true;
                    e = new MouseEventArgs(MouseButtons.Right, 0, structure.pt.X, structure.pt.Y, 0);
                    this.OnButtonDown(e);
                    goto Label_0158;

                case 0x205:
                    this.RightDown = false;
                    e = new MouseEventArgs(MouseButtons.Right, 0, structure.pt.X, structure.pt.Y, 0);
                    this.OnButtonUp(e);
                    goto Label_0158;

                default:
                    goto Label_0158;
            }
            e = new MouseEventArgs(none, 0, structure.pt.X, structure.pt.Y, 0);
            this.OnMouseMove(e);
        Label_0158:
            return base.OnProc(code, wParam, lParam);
        }
예제 #33
0
        /// <summary>
        /// Writes the action data.
        /// </summary>
        /// <param name="mouseEvents">The mouse events.</param>
        /// <param name="myMouse">My mouse.</param>
        /// <param name="delayTime">The delay time.</param>
        public void WriteData(string mouseEvents, MSLLHOOKSTRUCT myMouse, int delayTime)
        {
            XmlElement newAction = actionsXmlDoc.CreateElement("Action");
            XmlAttribute newActionAttris = actionsXmlDoc.CreateAttribute("Type");
            newActionAttris.InnerText = ActionTypes.MouseAct.ToString();
            newAction.SetAttributeNode(newActionAttris);
            newActionAttris = actionsXmlDoc.CreateAttribute("DelayTime");
            newActionAttris.InnerText = delayTime.ToString();
            newAction.SetAttributeNode(newActionAttris);

            XmlElement newKeyData = actionsXmlDoc.CreateElement("Position");
            newKeyData.InnerText = myMouse.pt.ToString();
            newAction.AppendChild(newKeyData);

            XmlElement newkeyEvent = actionsXmlDoc.CreateElement("MouseEvent");
            newkeyEvent.InnerText = mouseEvents;
            newAction.AppendChild(newkeyEvent);

            actionsXmlDoc.DocumentElement.AppendChild(newAction);
        }
예제 #34
0
 public void WriteDataTest1()
 {
     MActionRecorderLinq target = new MActionRecorderLinq();
     string mouseEvents = "WM_LBUTTONDOWN";
     MSLLHOOKSTRUCT myMouse = new MSLLHOOKSTRUCT() { pt = new Win32API.POINT(0, 0) };
     int delayTime = 10;
     target.WriteData(mouseEvents, myMouse, delayTime);
     target.SaveActions();
     Win32API.MouseEvent Expected = new Win32API.MouseEvent()
     {
         dwFlags = Win32API.MouseEventFlag.LeftDown,
         delayTime = 10,
         pt = new Win32API.POINT(0, 0)
     };
     var actual = target.GetDatas()[0];
     Assert.AreEqual(Expected, actual);
 }
예제 #35
0
            internal void Init(int wParam, MSLLHOOKSTRUCT lParam)
            {
                this.m_cancel = false;
                this.m_isValueUpdate = false;
                this.m_nativeWParam = wParam;
                this.m_nativeLParam = lParam;

                switch (wParam)
                {
                    case WM_LBUTTONDOWN:
                    case WM_LBUTTONUP:
                        this.m_button = MouseButtons.Left;
                        break;
                    case WM_MBUTTONDOWN:
                    case WM_MBUTTONUP:
                        this.m_button = MouseButtons.Middle;
                        break;
                    case WM_RBUTTONDOWN:
                    case WM_RBUTTONUP:
                        this.m_button = MouseButtons.Right;
                        break;

                    //case WM_XBUTTONDOWN:
                    //  break;

                    default:
                        this.m_button = MouseButtons.None;
                        break;
                }
                this.m_x = lParam.pt.x;
                this.m_y = lParam.pt.y;
                this.m_delta = (wParam == WM_MOUSEWHEEL)
                    ? (int)((short)(lParam.mouseData >> 16)) : 0;
                this.m_time = lParam.time;
            }
예제 #36
0
        public static MouseActivityArgs CreateFromLowLevelHookProc(int msg, MSLLHOOKSTRUCT eventData)
        {
            int x = eventData.X;
            int y = eventData.Y;
            int clicks = 0;
            short delta = 0;
            IntPtr windowHandle = IntPtr.Zero;
            int keyMasks = eventData.flags;

            MouseActivityType maType = ConvertMessageToActivityType(msg);
            MouseMovementType mmType = MouseMovementType.Absolute;
            MouseButtonActivity mbActivity = ConvertMessageToButtonActivityType(msg, out clicks);

            switch (msg)
            {
                case (int)WinMsg.WM_MOUSEWHEEL:
                    delta = (short)eventData.Delta;
                    break;
            }

            MouseActivityArgs args = new MouseActivityArgs(null, maType, mbActivity,
                MouseCoordinateSpace.Window, mmType, windowHandle, x, y, delta, clicks, keyMasks);

            return args;
        }
예제 #37
0
파일: MouseHook.cs 프로젝트: glwu/acat
        /// <summary>
        /// Notifies subscribers of the mouse event
        /// </summary>
        /// <param name="wParam">wParam</param>
        /// <param name="mouseHookStruct">Contains event info</param>
        /// <param name="handled">set to true if handled</param>
        private void notifyEvent(MouseWParam wParam, MSLLHOOKSTRUCT mouseHookStruct, ref bool handled)
        {
            var button = MouseButtons.None;
            MouseEventHandler mouseEvent = null;
            int delta = 0;

            switch (wParam)
            {
                case MouseWParam.WM_NCLBUTTONDOWN:
                case MouseWParam.WM_LBUTTONDOWN:
                    button = MouseButtons.Left;
                    mouseEvent = EvtMouseDown;
                    break;

                case MouseWParam.WM_RBUTTONDOWN:
                case MouseWParam.WM_NCRBUTTONDOWN:
                    button = MouseButtons.Right;
                    mouseEvent = EvtMouseDown;
                    break;

                case MouseWParam.WM_MBUTTONDOWN:
                case MouseWParam.WM_NCMBUTTONDOWN:
                    button = MouseButtons.Middle;
                    mouseEvent = EvtMouseDown;
                    break;

                case MouseWParam.WM_NCLBUTTONUP:
                case MouseWParam.WM_LBUTTONUP:
                    button = MouseButtons.Left;
                    mouseEvent = EvtMouseUp;
                    break;

                case MouseWParam.WM_RBUTTONUP:
                case MouseWParam.WM_NCRBUTTONUP:
                    button = MouseButtons.Right;
                    mouseEvent = EvtMouseUp;
                    break;

                case MouseWParam.WM_MBUTTONUP:
                case MouseWParam.WM_NCMBUTTONUP:
                    button = MouseButtons.Middle;
                    mouseEvent = EvtMouseUp;
                    break;

                case MouseWParam.WM_MOUSEMOVE:
                case MouseWParam.WM_NCMOUSEMOVE:
                    mouseEvent = EvtMouseMove;
                    break;

                case MouseWParam.WM_NCLBUTTONDBLCLK:
                case MouseWParam.WM_LBUTTONDBLCLK:
                    button = MouseButtons.Left;
                    mouseEvent = EvtMouseDblClick;
                    break;

                case MouseWParam.WM_NCRBUTTONDBLCLK:
                case MouseWParam.WM_RBUTTONDBLCLK:
                    button = MouseButtons.Right;
                    mouseEvent = EvtMouseDblClick;
                    break;

                case MouseWParam.WM_NCMBUTTONDBLCLK:
                case MouseWParam.WM_MBUTTONDBLCLK:
                    button = MouseButtons.Middle;
                    mouseEvent = EvtMouseDblClick;
                    break;

                case MouseWParam.WM_MOUSEWHEEL:
                case MouseWParam.WM_MOUSEHWHEEL:
                    delta = mouseHookStruct.mouseData >> 16;
                    mouseEvent = EvtMouseWheel;
                    break;
            }

            if (mouseEvent != null)
            {
                var args = new MouseEventArgs(button, 1, mouseHookStruct.pt.x, mouseHookStruct.pt.y, delta);
                mouseEvent(this, args);
            }
        }
예제 #38
0
파일: Input.cs 프로젝트: samiy-xx/keysndr
 private static extern int CallNextHookEx(int hHook, int nCode, int wParam, ref MSLLHOOKSTRUCT lParam);
예제 #39
0
파일: Input.cs 프로젝트: samiy-xx/keysndr
 private static int MouseProc(int nCode, int wParam, ref MSLLHOOKSTRUCT lParam)
 {
     //If it is a Mouse event
     if (nCode == HC_ACTION)
     {
         if (wParam == WM_MOUSEMOVE)
         {
             //If the mouse is moving...
             if (MouseMove != null) MouseMove(lParam.pt);
         }
         else if (wParam == WM_LBUTTONDOWN || wParam == WM_LBUTTONUP || wParam == WM_LBUTTONDBLCLK || wParam == WM_RBUTTONDOWN || wParam == WM_RBUTTONUP || wParam == WM_RBUTTONDBLCLK || wParam == WM_MBUTTONDOWN || wParam == WM_MBUTTONUP || wParam == WM_MBUTTONDBLCLK)
         {
             //If a mouse button event happend...
             if (MouseEvent != null) MouseEvent((MouseEvents)wParam);
         }
         else if (wParam == WM_MOUSEWHEEL)
         {
             //If the wheel moved...
             if (WheelEvent != null) WheelEvent((MouseWheelEvents)lParam.mouseData);
         }
     }
     //Calls the next hook chain
     return CallNextHookEx(MouseEventHook, nCode, wParam, ref lParam);
 }
예제 #40
0
 public static extern int CallNextHookEx(IntPtr idHook, int nCode, int wParam, ref MSLLHOOKSTRUCT lParam);
예제 #41
0
 /// <summary>
 /// Hook the MouseEvent event.
 /// </summary>
 /// <param name="mouseEvent">The mouse event.</param>
 /// <param name="myMouse">My mouse.</param>
 /// <param name="delayTime">The delay time.</param>
 void MHook_MouseEvent( MouseEvents mouseEvent, MSLLHOOKSTRUCT myMouse,int delayTime)
 {
     OnRecording(mouseEvent.ToString()+"|"+myMouse.pt.ToString());
     mActionRecorder.WriteData(mouseEvent.ToString(), myMouse, delayTime);
 }
예제 #42
0
        private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            //if (nCode >= 0 && MouseMessages.WM_MOUSEMOVE == (MouseMessages)wParam)
            //{

            //    hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
            //    //释放
            //    Marshal.FreeCoTaskMem(lParam);

            //    this.Text = hookStruct.pt.x + ", " + hookStruct.pt.y+","+hookStruct.dwExtraInfo.ToString();
            //}
            if (nCode >= 0 && MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam)
            {

                hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                //释放
                Marshal.FreeCoTaskMem(lParam);

                //this.Text = hookStruct.pt.x + ", " + hookStruct.pt.y + "," + hookStruct.dwExtraInfo.ToString();
                this.Location = (new Point(hookStruct.pt.x, hookStruct.pt.y));
                this.Show();
                this.TopMost = true;
            }

            return CallNextHookEx(_hookID, nCode, wParam, lParam);
        }
예제 #43
0
        static IntPtr HookProc(int nCode, IntPtr wParam, ref MSLLHOOKSTRUCT lParam)
        {
            bool cancel = false;
            if (nCode == HC_ACTION)
            {
                s_eventArgs.Init((int)wParam, lParam);
                switch (wParam.ToInt32())
                {
                    case WM_LBUTTONDOWN:
                    case WM_MBUTTONDOWN:
                    case WM_RBUTTONDOWN:
                        //case WM_XBUTTONDOWN:
                        CallEvent(MouseDown, s_eventArgs);
                        break;

                    case WM_LBUTTONUP:
                    case WM_MBUTTONUP:
                    case WM_RBUTTONUP:
                        //case WM_XBUTTONUP:
                        CallEvent(MouseUp, s_eventArgs);
                        break;

                    case WM_MOUSEMOVE:
                        CallEvent(MouseMove, s_eventArgs);
                        break;
                    case WM_MOUSEWHEEL:
                        CallEvent(MouseWheel, s_eventArgs);
                        break;
                }
                if (s_eventArgs.IsValueUpdate)
                {
                    wParam = (IntPtr)s_eventArgs.NativeWParam;
                    lParam = s_eventArgs.NativeLParam;
                }
                cancel = s_eventArgs.Cancel;
            }
            return cancel ? (IntPtr)1 : CallNextHookEx(s_hook, nCode, wParam, ref lParam);
        }
예제 #44
0
 /// <summary>
 /// HOOK MouseEvent event.
 /// </summary>
 /// <param name="mouseEvent">The mouse event.</param>
 /// <param name="mouse">The mouse.</param>
 /// <param name="delayTime">The delay time.</param>
 void kbmHOOK_MouseEvent(MouseEvents mouseEvent, MSLLHOOKSTRUCT mouse, int delayTime)
 {
     OnRecording(mouseEvent.ToString() + "|" + mouse.pt.ToString());
     this.kbmActionRecorder.WriteData(mouseEvent.ToString(), mouse, delayTime);
 }
예제 #45
0
파일: WinAPI.cs 프로젝트: hiiru/lab
 public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, ref MSLLHOOKSTRUCT lParam);