Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. namespace WindowsFormsApplication8
  2. {
  3. public partial class Form1 : Form
  4. {
  5. System.Timers.Timer myTimer = new System.Timers.Timer();
  6.  
  7. public Form1()
  8. {
  9. InitializeComponent();
  10. }
  11.  
  12. private void Form1_Load(object sender, EventArgs e)
  13. {
  14. myTimer.Elapsed += new ElapsedEventHandler( DisplayTimeEvent );
  15. myTimer.Interval = 1000;
  16. myTimer.Start();
  17. }
  18.  
  19. public void DisplayTimeEvent( object source, ElapsedEventArgs e )
  20. {
  21. MoveCursor();
  22. }
  23.  
  24. private void MoveCursor()
  25. {
  26. this.Cursor = new Cursor(Cursor.Current.Handle);
  27. Cursor.Position = new Point(Cursor.Position.X - 10, Cursor.Position.Y - 10);
  28. }
  29. }
  30. }
  31.  
  32. this.Dispatcher.BeginInvoke((Action)(() =>
  33. {
  34. MoveMouse();
  35. }));
  36.  
  37. namespace WindowsFormsApplication8
  38. {
  39. public partial class Form1 : Form
  40. {
  41. System.Timers.Timer myTimer = new System.Timers.Timer();
  42.  
  43. public Form1()
  44. {
  45. InitializeComponent();
  46. }
  47.  
  48. private void Form1_Load(object sender, EventArgs e)
  49. {
  50. myTimer.Tick += myTimer_Tick;
  51. myTimer.Interval = 1000;
  52. myTimer.Start();
  53. }
  54.  
  55. void myTimer_Tick(object sender, EventArgs e)
  56. {
  57. System.Threading.Thread.Sleep(5000); // 5000 is 5 seconds. i.e. after 5 seconds i am changing the cursor position.
  58. MoveCursor();
  59. }
  60.  
  61. private void MoveCursor()
  62. {
  63. this.Cursor = new Cursor(Cursor.Current.Handle);
  64. Cursor.Position = new Point(Cursor.Position.X - 10, Cursor.Position.Y - 10);
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement