示例#1
0
        /// <summary>Inject a fake left mouse click on a target window, on a location expressed in client coordinates.</summary>
        /// <param name="window">Target window to click on.</param>
        /// <param name="clickLocation">Location of the mouse click expressed in client coordiantes of the target window.</param>
        /// <param name="doubleClick">True if a double click should be injected.</param>
        public static void InjectFakeMouseClick(IntPtr window, CloneClickEventArgs clickArgs)
        {
            NPoint clientClickLocation = NPoint.FromPoint(clickArgs.ClientClickLocation);
            NPoint scrClickLocation = WindowManagerMethods.ClientToScreen(window, clientClickLocation);

            //HACK (?)
            //If target window has a Menu (which appears on the thumbnail) move the clicked location down
            //in order to adjust (the menu isn't part of the window's client rect).
            IntPtr hMenu = WindowMethods.GetMenu(window);
            if (hMenu != IntPtr.Zero)
                scrClickLocation.Y -= SystemInformation.MenuHeight;

            IntPtr hChild = GetRealChildControlFromPoint(window, scrClickLocation);
            NPoint clntClickLocation = WindowManagerMethods.ScreenToClient(hChild, scrClickLocation);

            if (clickArgs.Buttons == MouseButtons.Left) {
                if(clickArgs.IsDoubleClick)
                    InjectDoubleLeftMouseClick(hChild, clntClickLocation);
                else
                    InjectLeftMouseClick(hChild, clntClickLocation);
            }
            else if (clickArgs.Buttons == MouseButtons.Right) {
                if(clickArgs.IsDoubleClick)
                    InjectDoubleRightMouseClick(hChild, clntClickLocation);
                else
                    InjectRightMouseClick(hChild, clntClickLocation);
            }
        }
示例#2
0
        /// <summary>Inject a fake left mouse click on a target window, on a location expressed in client coordinates.</summary>
        /// <param name="window">Target window to click on.</param>
        /// <param name="clickLocation">Location of the mouse click expressed in client coordiantes of the target window.</param>
        /// <param name="doubleClick">True if a double click should be injected.</param>
        public static void InjectFakeMouseClick(IntPtr window, CloneClickEventArgs clickArgs)
        {
            NPoint clientClickLocation = NPoint.FromPoint(clickArgs.ClientClickLocation);
            NPoint scrClickLocation    = WindowManagerMethods.ClientToScreen(window, clientClickLocation);

            //HACK (?)
            //If target window has a Menu (which appears on the thumbnail) move the clicked location down
            //in order to adjust (the menu isn't part of the window's client rect).
            IntPtr hMenu = WindowMethods.GetMenu(window);

            if (hMenu != IntPtr.Zero)
            {
                scrClickLocation.Y -= SystemInformation.MenuHeight;
            }

            IntPtr hChild            = GetRealChildControlFromPoint(window, scrClickLocation);
            NPoint clntClickLocation = WindowManagerMethods.ScreenToClient(hChild, scrClickLocation);

            if (clickArgs.Buttons == MouseButtons.Left)
            {
                if (clickArgs.IsDown && MouseButtonDown == false)
                {
                    InjectLeftMouseDown(hChild, clntClickLocation);
                    MouseButtonDown = true;
                }
                else if (clickArgs.IsDown && MouseButtonDown)
                {
                    InjectLeftMouseMove(hChild, clntClickLocation);
                    MouseButtonDown = true;
                }

                else if (clickArgs.IsDown == false)
                {
                    InjectLeftMouseUp(hChild, clntClickLocation);

                    MouseButtonDown = false;
                }
            }

            else if (clickArgs.Buttons == MouseButtons.Right)
            {
                if (clickArgs.IsDown)
                {
                    InjectRightMouseDown(hChild, clntClickLocation);
                }
                else if (clickArgs.IsDown == false)
                {
                    InjectRightMouseUp(hChild, clntClickLocation);
                }
            }
        }
示例#3
0
        public static void MoveMouseToScreen(IntPtr window, CloneClickEventArgs clickArgs)
        {
            NPoint clientClickLocation = NPoint.FromPoint(clickArgs.ClientClickLocation);
            NPoint scrClickLocation = WindowManagerMethods.ClientToScreen(window, clientClickLocation);

            /*//HACK (?)
            //If target window has a Menu (which appears on the thumbnail) move the clicked location down
            //in order to adjust (the menu isn't part of the window's client rect).
            IntPtr hMenu = WindowMethods.GetMenu(window);
            if (hMenu != IntPtr.Zero)
                scrClickLocation.Y -= SystemInformation.MenuHeight;
            */

            //IntPtr hChild = GetRealChildControlFromPoint(window, scrClickLocation);
            //NPoint clntClickLocation = WindowManagerMethods.ScreenToClient(hChild, scrClickLocation);
            Cursor.Position = new Point(scrClickLocation.X, scrClickLocation.Y);
            #if DEBUG
            Console.WriteLine("Sending cursor to " + scrClickLocation.ToString() + " with thumb coords " + clientClickLocation.ToString());
            #endif
            //Cursor.Position = new Point(Cursor.Position.X + 300, Cursor.Position.Y + 300);
        }
示例#4
0
 void Thumbnail_CloneClick(object sender, CloneClickEventArgs e)
 {
     /*if (e.ClientClickLocation.X - _thumbnailPanel.Location.X < 0 ||  e.ClientClickLocation.Y - _thumbnailPanel.Location.Y < 0)
     {
         Console.WriteLine("Error out of bounds! too small" + e.ClientClickLocation.ToString());
         return;
     }
     if (_thumbnailPanel.Location.X + _thumbnailPanel.Size.Width - e.ClientClickLocation.X < 0 ||
         _thumbnailPanel.Location.Y + _thumbnailPanel.Size.Height - e.ClientClickLocation.Y < 0)
     {
         Console.WriteLine("Error out of bounds! too big" + e.ClientClickLocation.ToString());
         return;
     }*/
     Win32Helper.InjectFakeMouseClick(CurrentThumbnailWindowHandle.Handle, e);
     //CloneClickEventArgs fixedArgs = new CloneClickEventArgs(new Point(e.ClientClickLocation.X-Location.X, e., MouseButtons.Left);
     Win32Helper.MoveMouseToScreen(CurrentThumbnailWindowHandle.Handle, e);
 }
示例#5
0
 void Thumbnail_CloneClick(object sender, CloneClickEventArgs e)
 {
     Win32Helper.InjectFakeMouseClick(CurrentThumbnailWindowHandle.Handle, e);
 }
示例#6
0
 void Thumbnail_CloneClick(object sender, CloneClickEventArgs e)
 {
     Win32Helper.InjectFakeMouseClick(CurrentThumbnailWindowHandle.Handle, e);
 }