This
article will show you how you can move mouse cursor automatically on button
click using c#.net in your windows application. This will help yo understand move mouse pointer using c#, c# set mouse position, c# simulate mouse move.
Now for this article first we will create a new windows application and add a button control. On this click event of button control we will add the below code.
Now for this article first we will create a new windows application and add a button control. On this click event of button control we will add the below code.
using System;
using
System.Collections.Generic;
using
System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using
System.Windows.Forms;
namespace MoveMyMouse
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnMove_Click(object sender, EventArgs e)
{
Cursor
= new Cursor(Cursor.Current.Handle);
Cursor.Position = new Point(Cursor.Position.X - 20, Cursor.Position.Y - 20);
}
}
}
|
Here in
above code I have created handler for cursor and then reset the cursor position
by adding dome value on x and y coordinate. And at end I have reset the cursor
position.
0 comments:
Please let me know your view