コード例 #1
0
        internal static bool IsForeground(IntPtr ptr)
        {
            IntPtr hwnd = ProcessHandler.GetForegroundWindow();

            if (hwnd.ToString().Equals(ptr.ToString()))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        private void RunPaint()
        {
            Console.WriteLine("Welcome to EliteDangerousCrosshair v1.0.1 by RobCubed!");
            Console.WriteLine("http://www.github.com/RobCubed");
            Console.WriteLine("* * * Now works on multi-screens/any screen! * * *");
            Console.WriteLine("Remember, Elite Dangerous *must* be in windowed mode for this to function.");
            Console.WriteLine("CTRL+SHIFT+F1 will enable/disable the crosshairs.");
            Console.WriteLine("--------------------------------------------");
            string gameName = "EliteDangerous32";
            IntPtr ptr      = ProcessHandler.WaitForProcessByName(gameName);

            EDCrossHair.ProcessHandler.RECT clientRect = ProcessHandler.GetRect(ptr);


            bool coordinatesFound;
            int  newPointX;
            int  newPointY;


            while (true)
            {
                if (activate)
                {
                    ptr        = ProcessHandler.WaitForProcessByName(gameName);
                    clientRect = ProcessHandler.GetRect(ptr);

                    if (ProcessHandler.IsForeground(ptr))
                    {
                        bufferedPanel.programFocus = true;
                    }
                    else
                    {
                        bufferedPanel.programFocus = false;
                    }

                    Point point;
                    x = clientRect.Width / 2;
                    y = clientRect.Height / 2;
                    coordinatesFound = false;


                    point = new Point();

                    coordinatesFound = ProcessHandler.ClientToScreen(ptr, ref point);

                    finalLocX = point.X;
                    finalLocY = point.Y;

                    if (!locationUpdate.IsBusy)
                    {
                        locationUpdate.RunWorkerAsync();
                    }


                    newPointX = point.X + x;
                    newPointY = point.Y + y;



                    if (coordinatesFound == true && (newPointX != bufferedPanel.xDraw || newPointY != bufferedPanel.yDraw))
                    {
                        bufferedPanel.xDraw   = newPointX;
                        bufferedPanel.yDraw   = newPointY;
                        bufferedPanel.xScreen = clientRect.Width;
                        bufferedPanel.yScreen = clientRect.Height;
                    }
                }
                else
                {
                    bufferedPanel.programFocus = false;
                }
            }
        }