Beispiel #1
0
        /// <summary>
        /// Init the window rect from process window and calculate the caprure rect
        /// </summary>
        /// <param name="procName">process name</param>
        /// <param name="Profil">active profile</param>
        public void GetGameWindowRect(string procName, ProfileData Profil)
        {
            Process proc;

            try
            {
                if (String.IsNullOrEmpty(procName))
                {
                    CRect = new Rectangle(0, 0, 0, 0);
                    return;
                }

                proc = Process.GetProcessesByName(procName)[0];
                if (proc == null)
                {
                    CRect = new Rectangle(0, 0, 0, 0);
                    return;
                }

                GameWindowRect = new User32.Rect();
                IntPtr error = User32.GetWindowRect(proc.MainWindowHandle, ref GameWindowRect);

                while (error == (IntPtr)0)
                {
                    error = User32.GetWindowRect(proc.MainWindowHandle, ref GameWindowRect);
                }


                SetCaptureRect(Profil);
            }
            catch
            {
                CRect = new Rectangle(0, 0, 0, 0);
            }
        }
        /// <summary>
        /// Init the window rect from process window and calculate the caprure rect
        /// </summary>
        /// <param name="procName">process name</param>
        /// <param name="Profil">active profile</param>
        public void GetGameWindowRect(string procName, ProfileData Profil)
        {
            Process proc;
            try
            {
                if (String.IsNullOrEmpty(procName))
                {
                    CRect = new Rectangle(0, 0, 0, 0);
                    return;
                }

                proc = Process.GetProcessesByName(procName)[0];
                if (proc == null)
                {
                    CRect = new Rectangle(0, 0, 0, 0);
                    return;
                }

                GameWindowRect = new User32.Rect();
                IntPtr error = User32.GetWindowRect(proc.MainWindowHandle, ref GameWindowRect);

                while (error == (IntPtr)0)
                {
                    error = User32.GetWindowRect(proc.MainWindowHandle, ref GameWindowRect);
                }


                SetCaptureRect(Profil);

            }
            catch
            {
                CRect = new Rectangle(0, 0, 0, 0);
            }
        }