Click here to Skip to main content
15,897,187 members

reduce speed of mouse

farham_heidari asked:

Open original thread
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;


       }
Tags: C#

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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