Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Threading;
- using System.Windows.Forms;
- using System.Drawing.Imaging;
- class FridayThe13th
- {
- private static void atPointZero()
- {
- Cursor Cursor = new Cursor(Cursor.Current.Handle);
- Cursor.Position = new Point(0, 0);
- Cursor.Clip = Screen.PrimaryScreen.Bounds;
- }
- private static void atPoint(int X, int Y)
- {
- Cursor Cursor = new Cursor(Cursor.Current.Handle);
- int CursorPositionX = Cursor.Position.X;
- int CursorPositionY = Cursor.Position.Y;
- while (CursorPositionX != X & CursorPositionY != Y)
- {
- Cursor.Position = new Point(CursorPositionX, CursorPositionY);
- if (CursorPositionY % 2 != 0 | CursorPositionX % 2 != 0) {Thread.Sleep(2);}
- if (CursorPositionX < X) {CursorPositionX += 1;} else if (CursorPositionX > X) {CursorPositionX -= 1;}
- if (CursorPositionY < Y) {CursorPositionY += 1;} else if (CursorPositionY > Y) {CursorPositionY -= 1;}
- }
- Cursor.Clip = Screen.PrimaryScreen.Bounds;
- }
- private static void GetPixel()
- {
- var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
- Screen.PrimaryScreen.Bounds.Height,
- PixelFormat.Format32bppArgb);
- // Create a graphics object from the bitmap.
- var gfxScreenshot = Graphics.FromImage(bmpScreenshot);
- // Take the screenshot from the upper left corner to the right bottom corner.
- gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
- Screen.PrimaryScreen.Bounds.Y,
- 0,
- 0,
- Screen.PrimaryScreen.Bounds.Size,
- CopyPixelOperation.SourceCopy);
- // Save the screenshot to the specified path that the user has chosen.
- bmpScreenshot.Save("Screenshot.png", ImageFormat.Png);
- // Create a Bitmap object from an image file.
- Bitmap myBitmap = new Bitmap("Screenshot.png");
- // Get the color of a pixel within myBitmap.
- // Fill a rectangle with pixelColor.
- Cursor Cursor = new Cursor(Cursor.Current.Handle);
- for (int i = 0; i < Screen.PrimaryScreen.Bounds.Height; i++)
- {
- Color pixelColor = myBitmap.GetPixel(10, i);
- if (pixelColor.R == 0 & pixelColor.G == 112 & pixelColor.B == 159)
- {
- Cursor.Position = new Point(10, i);
- }
- }
- Cursor.Position = new Point(100, 100);
- Thread.Sleep(2000);
- }
- static void Main() {
- atPointZero();
- atPoint(100,100);
- Thread.Sleep(1000);
- atPoint(1000,1000);
- }
- }
Add Comment
Please, Sign In to add comment