Exemple #1
0
        public static void ForceForegroundWindow(IntPtr hWnd)
        {
            uint windowThreadProcessId = ProgramThread.GetWindowThreadProcessId(ProgramThread.GetForegroundWindow(), IntPtr.Zero);

            uint currentThreadId = ProgramThread.GetCurrentThreadId();

            if (windowThreadProcessId != currentThreadId)
            {
                ProgramThread.AttachThreadInput(windowThreadProcessId, currentThreadId, true);
                ProgramThread.BringWindowToTop(hWnd);
                ProgramThread.ShowWindow(hWnd, ProgramThread.ShowWindowCommands.Show);
                ProgramThread.AttachThreadInput(windowThreadProcessId, currentThreadId, false);
            }
            else
            {
                ProgramThread.BringWindowToTop(hWnd);
                ProgramThread.ShowWindow(hWnd, ProgramThread.ShowWindowCommands.Show);
            }
        }
Exemple #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);
        }