Example #1
0
        public static bool WindowHasMouseOver(Process process)
        {
            IntPtr mainWindowHandle = process.MainWindowHandle;
            bool   result;

            if (mainWindowHandle == IntPtr.Zero || process.HasExited)
            {
                result = false;
            }
            else if (ProgramThread.GetForegroundWindow() != mainWindowHandle)
            {
                result = false;
            }
            else
            {
                ProgramThread.WINDOWPLACEMENT wINDOWPLACEMENT = default(ProgramThread.WINDOWPLACEMENT);
                if (!ProgramThread.GetWindowPlacement(mainWindowHandle, ref wINDOWPLACEMENT))
                {
                    result = false;
                }
                else if (wINDOWPLACEMENT.showCmd != ProgramThread.ShowWindowCommands.Normal)
                {
                    result = false;
                }
                else
                {
                    ProgramThread.RECT rECT = default(ProgramThread.RECT);
                    if (!ProgramThread.GetWindowRect(mainWindowHandle, out rECT))
                    {
                        result = false;
                    }
                    else
                    {
                        ProgramThread.MousePoint mousePoint;
                        ProgramThread.GetCursorPos(out mousePoint);
                        Point position = new Point(mousePoint.X, mousePoint.Y);
                        result = rECT.Contains(position);
                    }
                }
            }
            return(result);
        }
Example #2
0
        private static void AutoClickPatcher()
        {
            Process process = Process.GetProcessesByName("LolPatcherUx").FirstOrDefault((Process p) => p.MainWindowHandle != IntPtr.Zero && p.MainWindowTitle == "LoL Patcher");

            while (!process.HasExited && process.MainWindowHandle != IntPtr.Zero)
            {
                Color pixelColor = ProgramThread.GetPixelColor(process, 645, 35);
                if (pixelColor.R == 218 && pixelColor.G == 170 && pixelColor.B == 124)
                {
                    break;
                }
                Thread.Sleep(100);
            }
            ProgramThread.SetForegroundWindow(process.MainWindowHandle);
            ProgramThread.ForceForegroundWindow(process.MainWindowHandle);
            ProgramThread.BringWindowToTop(process.MainWindowHandle);
            ProgramThread.ShowWindow(process.MainWindowHandle, ProgramThread.ShowWindowCommands.Show);
            ProgramThread.RECT       windowRect = ProgramThread.GetWindowRect(process.MainWindowHandle);
            ProgramThread.MousePoint mousePoint;
            ProgramThread.GetCursorPos(out mousePoint);
            ProgramThread.SetCursorPos(windowRect.Left + 645, windowRect.Top + 35);
            ProgramThread.mouse_event(6u, 645u, 35u, 0u, 0u);
            ProgramThread.SetCursorPos(mousePoint.X, mousePoint.Y);
        }
Example #3
0
 public static ProgramThread.RECT GetWindowRect(IntPtr handle)
 {
     ProgramThread.RECT result;
     ProgramThread.GetWindowRect(handle, out result);
     return(result);
 }