i have machine that move mouse ,this machine work in large scale 2m height and 2m width i want use this machine for movie mouse ... i just want a program to reduce mouse speed , i wrote this code ...
i have 2 problem
1- mouse jump 9 px back every 10 px i just want stop the mouse until user move mouse 10 px and then move mose 1 px .. let me explain more if my machine move mouse 10 px the mouse move 1 px on the scree...
2- when i move mouse with very fast speed my program doesn't work because timer1_Tick get my mouse position every 0.001 second and it's make a bigger problem plz help :((
{
[DllImport("user32.dll", CharSet = CharSet.Auto),]
public static extern int SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);
}
public Int32 xcolb = 10;
public Int32 ycolb = 10;
private void Form1_Load(object sender, EventArgs e)
{
timer1.Interval = 1;
timer1.Enabled = true;
uint SPEED = 1;
int res = WinAPI.SystemParametersInfo(113, 0, SPEED, 0);
textBox3.Text = SPEED.ToString();
x = Cursor.Position.X;
y = Cursor.Position.Y;
prevx = Cursor.Position.X;
prevy = Cursor.Position.Y;
Screen Srn = Screen.PrimaryScreen;
tempHeight =Convert.ToInt32(Srn.Bounds.Height);
tempWidth =Convert.ToInt32( Srn.Bounds.Width);
label9.Text = tempWidth.ToString() + " x " + tempHeight.ToString();
SetCursorPos(-1, 0);
}
private void timer1_Tick(object sender, EventArgs e)
{
x = Cursor.Position.X;
y = Cursor.Position.Y;
textBox1.Text = x.ToString();
textBox2.Text = y.ToString();
if (x > prevx)
{
if (x - prevx > xcolb)
{
SetCursorPos(x -9, y);
prevx = x -9;
}
}
else if (x < prevx)
{
if (prevx - x > xcolb)
{
SetCursorPos(x + 9, y);
prevx = x +5;
}
}
if (y> prevy)
{
if (y - prevy > ycolb)
{
SetCursorPos(x ,y - 9 );
prevy = y -9;
}
}
else if (y < prevy)
{
if (prevy - y > ycolb)
{
SetCursorPos(x, y+5);
prevy = y +9;
}
}
if (flag)
{
button1.Text = "Move Mouse To calibre";
if (x > prevx)
{
textBox5.Text = x.ToString();
}
if (y> prevy)
{
textBox4.Text = y.ToString();
}
}
else
{
button1.Text = "calibre";
}
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
int res = WinAPI.SystemParametersInfo(113, 0, 10, 0);
}
private void button1_Click(object sender, EventArgs e)
{
Form2 frm = new Form2();
frm.ShowDialog();
}
public bool flag = false;
private void button1_Click_1(object sender, EventArgs e)
{
flag = true;
}