Advertisement
Jakobhorak28

Untitled

Apr 14th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 KB | None | 0 0
  1.     class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             System.Drawing.Point oldpoint = new System.Drawing.Point();
  6.             TimeMeasurement time = new TimeMeasurement();
  7.             Thread countUpThread = new Thread(new ThreadStart(time.CountUp));
  8.             countUpThread.Start();
  9.             time.elapsed = 0;
  10.             while (true)
  11.             {
  12.                 oldpoint = System.Windows.Forms.Cursor.Position;
  13.                 Thread.Sleep(1);
  14.                 if (oldpoint != System.Windows.Forms.Cursor.Position)
  15.                     Console.WriteLine($"{time.elapsed}ms; Y: {System.Windows.Forms.Cursor.Position.Y - oldpoint.Y}; X: {System.Windows.Forms.Cursor.Position.X - oldpoint.X}");
  16.             }
  17.         }
  18.     }
  19.  
  20.     class TimeMeasurement
  21.     {
  22.         private int elapsedPrivate;
  23.         public TimeMeasurement()
  24.         {
  25.             elapsedPrivate = 0;
  26.         }
  27.         public void CountUp()
  28.         {
  29.             try
  30.             {
  31.                 while (true)
  32.                 {
  33.                     Thread.Sleep(1);
  34.                     elapsedPrivate += 1;
  35.                 }
  36.             }
  37.             catch (Exception e) { }
  38.             finally { }
  39.         }
  40.         public int elapsed
  41.         {
  42.             set
  43.             {
  44.                 elapsedPrivate = value;
  45.             }
  46.             get
  47.             {
  48.                 int temp = elapsedPrivate;
  49.                 elapsedPrivate = 0;
  50.                 return temp;
  51.             }
  52.         }
  53.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement