Click here to Skip to main content
15,894,180 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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 :((

C#
{
           [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();
          // MessageBox.Show("Resolution is going to change to " + "1024" + " X " + "768");
          // Resolution.CResolution ChangeRes = new Resolution.CResolution(1024, 768);
           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;


       }
Posted
Comments
Jibesh 9-Jan-13 18:16pm    
how the mouse move in your application and and the machine are linked? is your mouse move has direct impact on the machine
farham_heidari 9-Jan-13 18:20pm    
yes
Sergey Alexandrovich Kryukov 9-Jan-13 19:08pm    
Bad idea. Why?!
—SA

1 solution

Reduce mouse speed?? I have no idea why you're doing this, but couldn't you just open the Mouse control panel, click on the Pointer Options tab and change the speed that way?? :confused:
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 9-Jan-13 19:10pm    
Aha, and someone even voted 1...

You are absolutely right. Why OP wants it? I don't know, but, following your advice, the user does it, but the inquirer wants to rape the user, that's why. :-)
My 5.

You see, a noticeable number of bad inquirer's ideas is not poor understanding of programming, but denial to respect some very elementary and fundamental user's rights...

—SA
Jibesh 9-Jan-13 19:51pm    
'the user does it, but the inquirer wants to rape the user, that's why. :-)'

:D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900