コード例 #1
0
        private void StartClicking(object sender, KeyPressEventArgs keyEventArguments)
        {
            if (keyEventArguments.KeyChar == 'p' && !IsClickingEnabled)
            {
                IColourPicker colourPicker  = new ColourPicker();
                IVideoDisplay display       = new WindowsScreen();
                IVideoDisplay currentWindow = WindowsApplication.GetForeground();
                ICursor       cursor        = new WindowsCursor();
                Color         colour        = colourPicker.GetFromDisplayPosition(display, cursor.GetPosition());
                IPixelFinder  pixelFinder   = new PixelFinder();

                IClicker clicker = new Clicker();

                Thread clickingThread = new Thread(() =>
                {
                    IsClickingEnabled = true;
                    while (IsClickingEnabled)
                    {
                        var clickedPosition = pixelFinder.FindPixelPosition(currentWindow, colour);

                        if (clickedPosition.HasValue)
                        {
                            clicker.Click((int)currentWindow.Handle, clickedPosition.Value);
                        }

                        Thread.Sleep(TimeSpan.FromSeconds(1));
                    }
                });

                clickingThread.Start();
            }
        }
コード例 #2
0
        public void LeftClick()
        {
            WindowsApplication currentApplication = WindowsApplication.GetForeground();

            bool isSuccess = WindowsCursor.LeftClick((int)currentApplication.Handle, 0, 0);

            Assert.IsTrue(isSuccess);
        }
コード例 #3
0
        public void GetFromDisplayPosition()
        {
            IVideoDisplay videoDisplay   = new WindowsScreen();
            ICursor       cursor         = new WindowsCursor();
            Point         cursorPosition = cursor.GetPosition();
            Color         colourAtCursor = ColourPicker.GetFromDisplayPosition(videoDisplay, cursorPosition);

            Assert.IsNotNull(colourAtCursor);
        }
コード例 #4
0
        public void FindPixelPosition()
        {
            IVideoDisplay videoDisplay   = new WindowsDisplay();
            ICursor       cursor         = new WindowsCursor();
            IColourPicker colorPicker    = new ColourPicker();
            Color         colourAtCursor = colorPicker.GetFromDisplayPosition(videoDisplay, cursor.GetPosition());
            var           point          = PixelFinder.FindPixelPosition(videoDisplay, colourAtCursor);

            Assert.IsNotNull(point, "Could not find the pixel you were hovering over on the screen.");
        }
コード例 #5
0
 public static void ChangeCursor(WindowsCursor cursor) => SetCursor(LoadCursor(IntPtr.Zero, (int)cursor));
コード例 #6
0
        public void GetPosition()
        {
            Point cursorPosition = WindowsCursor.GetPosition();

            Assert.AreNotEqual(new Point(0, 0), cursorPosition);
        }
コード例 #7
0
 public static void SetCursor(WindowsCursor cursor)
 {
     SetCursor(LoadCursor(IntPtr.Zero, (int)cursor));
 }