Guest User

Untitled

a guest
Aug 14th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Threading;
  4. using System.Windows.Forms;
  5. using System.Drawing.Imaging;
  6.  
  7. class FridayThe13th
  8. {
  9. private static void atPointZero()
  10. {
  11. Cursor Cursor = new Cursor(Cursor.Current.Handle);
  12. Cursor.Position = new Point(0, 0);
  13. Cursor.Clip = Screen.PrimaryScreen.Bounds;
  14. }
  15.  
  16. private static void atPoint(int X, int Y)
  17. {
  18. Cursor Cursor = new Cursor(Cursor.Current.Handle);
  19.  
  20. int CursorPositionX = Cursor.Position.X;
  21. int CursorPositionY = Cursor.Position.Y;
  22.  
  23. while (CursorPositionX != X & CursorPositionY != Y)
  24. {
  25. Cursor.Position = new Point(CursorPositionX, CursorPositionY);
  26.  
  27. if (CursorPositionY % 2 != 0 | CursorPositionX % 2 != 0) {Thread.Sleep(2);}
  28.  
  29. if (CursorPositionX < X) {CursorPositionX += 1;} else if (CursorPositionX > X) {CursorPositionX -= 1;}
  30. if (CursorPositionY < Y) {CursorPositionY += 1;} else if (CursorPositionY > Y) {CursorPositionY -= 1;}
  31. }
  32.  
  33. Cursor.Clip = Screen.PrimaryScreen.Bounds;
  34. }
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. private static void GetPixel()
  54. {
  55.  
  56.  
  57. var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
  58. Screen.PrimaryScreen.Bounds.Height,
  59. PixelFormat.Format32bppArgb);
  60.  
  61. // Create a graphics object from the bitmap.
  62. var gfxScreenshot = Graphics.FromImage(bmpScreenshot);
  63.  
  64. // Take the screenshot from the upper left corner to the right bottom corner.
  65. gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
  66. Screen.PrimaryScreen.Bounds.Y,
  67. 0,
  68. 0,
  69. Screen.PrimaryScreen.Bounds.Size,
  70. CopyPixelOperation.SourceCopy);
  71.  
  72. // Save the screenshot to the specified path that the user has chosen.
  73. bmpScreenshot.Save("Screenshot.png", ImageFormat.Png);
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. // Create a Bitmap object from an image file.
  82. Bitmap myBitmap = new Bitmap("Screenshot.png");
  83.  
  84. // Get the color of a pixel within myBitmap.
  85.  
  86. // Fill a rectangle with pixelColor.
  87.  
  88.  
  89. Cursor Cursor = new Cursor(Cursor.Current.Handle);
  90.  
  91.  
  92. for (int i = 0; i < Screen.PrimaryScreen.Bounds.Height; i++)
  93. {
  94.  
  95.  
  96. Color pixelColor = myBitmap.GetPixel(10, i);
  97.  
  98. if (pixelColor.R == 0 & pixelColor.G == 112 & pixelColor.B == 159)
  99. {
  100. Cursor.Position = new Point(10, i);
  101. }
  102.  
  103.  
  104. }
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. Cursor.Position = new Point(100, 100);
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125. Thread.Sleep(2000);
  126. }
  127.  
  128. static void Main() {
  129. atPointZero();
  130. atPoint(100,100);
  131. Thread.Sleep(1000);
  132. atPoint(1000,1000);
  133.  
  134. }
  135.  
  136.  
  137.  
  138. }
Add Comment
Please, Sign In to add comment