Пример #1
0
 private static void OpenTheGame(string launcherPath)
 {
     if (Process.GetProcessesByName("LoLLauncher").Length == 0)
     {
         Mutex mutex;
         bool  flag = Mutex.TryOpenExisting("RADS_USER_KERNEL_MUTEX_NAME", out mutex);
         if (flag)
         {
             try
             {
                 mutex.WaitOne();
             }
             catch (AbandonedMutexException)
             {
             }
         }
         Process.Start(new ProcessStartInfo
         {
             FileName         = launcherPath,
             WorkingDirectory = Path.GetDirectoryName(launcherPath)
         }).WaitForExit();
         while (!Mutex.TryOpenExisting("RADS_USER_KERNEL_MUTEX_NAME", out mutex))
         {
             Thread.Sleep(100);
         }
         ProgramThread.WaitForProcessWindow("LolPatcherUx");
     }
 }
Пример #2
0
        public static bool SimulateText(Process process, string value)
        {
            IntPtr mainWindowHandle = process.MainWindowHandle;
            bool   result;

            if (mainWindowHandle == IntPtr.Zero || process.HasExited)
            {
                result = false;
            }
            else
            {
                char[] array = value.ToCharArray();
                for (int i = 0; i < array.Length; i++)
                {
                    char wParam = array[i];
                    if (!ProgramThread.PostMessage(mainWindowHandle, 258u, (int)wParam, 0))
                    {
                        result = false;
                        return(result);
                    }
                }
                result = true;
            }
            return(result);
        }
Пример #3
0
        private static void AutoClickClient(string user, string pass)
        {
            Process process;

            if (ProgramThread.WaitForProcessWindow("LolClient", out process))
            {
                while (ProgramThread.IsWindowVisible(process.MainWindowHandle))
                {
                    if (process.HasExited)
                    {
                        return;
                    }
                    if (LolAutoLogger.PixelColorIsWite(process, 195, 320) && LolAutoLogger.PixelColorIsWite(process, 195, 380))
                    {
                        break;
                    }
                    Thread.Sleep(100);
                }
                ProgramThread.SimulateClick(process, 195, 320);
                ProgramThread.SimulateClick(process, 195, 320);
                ProgramThread.SimulateText(process, user);
                ProgramThread.SimulateClick(process, 195, 380);
                ProgramThread.SimulateClick(process, 195, 380);
                ProgramThread.SimulateText(process, pass);
                ProgramThread.SimulateClick(process, 375, 420);
            }
        }
Пример #4
0
        public static bool WaitForProcessWindow(string processName, TimeSpan timeout, CancellationToken cancellationToken, out Process process)
        {
            bool result;

            if (!ProgramThread.WaitForProcess(processName, out process))
            {
                result = false;
            }
            else
            {
                bool      flag      = timeout < TimeSpan.Zero;
                Stopwatch stopwatch = new Stopwatch();
                if (!flag)
                {
                    stopwatch.Start();
                }
                while (process.MainWindowHandle == IntPtr.Zero)
                {
                    if (process.HasExited)
                    {
                        process = null;
                        result  = false;
                        return(result);
                    }
                    Thread.Sleep(100);
                    if ((!flag && stopwatch.Elapsed > timeout) || cancellationToken.IsCancellationRequested)
                    {
                        process = null;
                        result  = false;
                        return(result);
                    }
                }
                while (!ProgramThread.IsWindowVisible(process.MainWindowHandle))
                {
                    if (process.HasExited)
                    {
                        process = null;
                        result  = false;
                        return(result);
                    }
                    Thread.Sleep(100);
                    if ((!flag && stopwatch.Elapsed > timeout) || cancellationToken.IsCancellationRequested)
                    {
                        process = null;
                        result  = false;
                        return(result);
                    }
                }
                result = true;
            }
            return(result);
        }
Пример #5
0
        public static Color GetPixelColor(Process process, int x, int y)
        {
            IntPtr mainWindowHandle = process.MainWindowHandle;
            Color  result;

            if (mainWindowHandle == IntPtr.Zero || process.HasExited)
            {
                result = Color.Empty;
            }
            else
            {
                IntPtr dC    = ProgramThread.GetDC(mainWindowHandle);
                uint   pixel = ProgramThread.GetPixel(dC, x, y);
                ProgramThread.ReleaseDC(mainWindowHandle, dC);
                result = Color.FromArgb((int)(pixel & 255u), (int)(pixel & 65280u) >> 8, (int)(pixel & 16711680u) >> 16);
            }
            return(result);
        }
Пример #6
0
        public static bool SimulateClick(Process process, int x, int y)
        {
            IntPtr mainWindowHandle = process.MainWindowHandle;
            bool   result;

            if (mainWindowHandle == IntPtr.Zero || process.HasExited)
            {
                result = false;
            }
            else
            {
                bool flag = ProgramThread.PostMessage(mainWindowHandle, 513u, 1, y << 16 | (x & 65535));
                Thread.Sleep(120);
                bool flag2 = ProgramThread.PostMessage(mainWindowHandle, 514u, 1, y << 16 | (x & 65535));
                result = (flag && flag2);
            }
            return(result);
        }
Пример #7
0
        public static bool PixelColorIsWite(Process process, int x, int y)
        {
            IntPtr mainWindowHandle = process.MainWindowHandle;
            bool   result;

            if (mainWindowHandle == IntPtr.Zero || process.HasExited)
            {
                result = false;
            }
            else
            {
                IntPtr dC    = ProgramThread.GetDC(mainWindowHandle);
                uint   pixel = ProgramThread.GetPixel(dC, x, y);
                ProgramThread.ReleaseDC(mainWindowHandle, dC);
                Color color = Color.FromArgb((int)(pixel & 255u), (int)(pixel & 65280u) >> 8, (int)(pixel & 16711680u) >> 16);
                result = (color.R > 240 && color.G > 240 && color.B > 240);
            }
            return(result);
        }
Пример #8
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);
            }
        }
Пример #9
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);
        }
Пример #10
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);
        }
Пример #11
0
 public static bool WaitForProcessWindow(string processName, TimeSpan timeout, out Process process)
 {
     return(ProgramThread.WaitForProcessWindow(processName, timeout, default(CancellationToken), out process));
 }
Пример #12
0
 public static bool WaitForProcessWindow(string processName, int millisecondsTimeout, out Process process)
 {
     return(ProgramThread.WaitForProcessWindow(processName, TimeSpan.FromMilliseconds((double)millisecondsTimeout), out process));
 }
Пример #13
0
 public static bool WaitForProcessWindow(string processName, out Process process)
 {
     return(ProgramThread.WaitForProcessWindow(processName, -1, out process));
 }
Пример #14
0
        public static bool WaitForProcess(string processName)
        {
            Process process;

            return(ProgramThread.WaitForProcess(processName, out process));
        }
Пример #15
0
 public static ProgramThread.RECT GetWindowRect(IntPtr handle)
 {
     ProgramThread.RECT result;
     ProgramThread.GetWindowRect(handle, out result);
     return(result);
 }