コード例 #1
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);
            }
        }
コード例 #2
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);
        }