Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 Cry | :((
 
 
 {
            [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 9-Jan-13 11:57am
Comments
jibesh at 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 at 9-Jan-13 18:20pm
   
yes
Sergey Alexandrovich Kryukov at 9-Jan-13 19:08pm
   
Bad idea. Why?! —SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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 | :confused:
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 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 at 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)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 457
1 OriginalGriff 430
2 Shai Vashdi 240
3 Emre Ataseven 165
4 Peter Leow 146
0 Sergey Alexandrovich Kryukov 8,944
1 OriginalGriff 5,280
2 Peter Leow 3,985
3 Maciej Los 3,535
4 Abhinav S 3,218


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid