Giving mouse movement lag

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • c.k.

    #1

    Giving mouse movement lag

    I was wondering if there was a way to give mouse movement on an empty form some lag/delay? For instance, user moves mouse, and the cursor is
    20ms (possible adjustable from some option) behind the movement. So when user stops moving mouse, 20ms later the cursor itself stops
    moving...
    I tried using:
    Windows.Forms.C ursor.Current.P osition = New System.Drawing. Point(x,y)
    and forms of sleep/timer events but cant seem to get it to work correctly....
    Well anyway if anyone knows how to do it, some help would be appreciated.
  • =?Utf-8?B?U3VydHVyWg==?=

    #2
    RE: Giving mouse movement lag

    I think making the mouse invisible and then displaying a fake mouse pointer
    would be your best bet, since you need to know where the "future" mouse will
    be.

    --
    David Streeter
    Synchrotech Software
    Sydney Australia


    "c.k." wrote:
    I was wondering if there was a way to give mouse movement on an empty form some lag/delay? For instance, user moves mouse, and the cursor is
    20ms (possible adjustable from some option) behind the movement. So when user stops moving mouse, 20ms later the cursor itself stops
    moving...
    I tried using:
    Windows.Forms.C ursor.Current.P osition = New System.Drawing. Point(x,y)
    and forms of sleep/timer events but cant seem to get it to work correctly....
    Well anyway if anyone knows how to do it, some help would be appreciated.
    >

    Comment

    • Michel Posseth  [MCP]

      #3
      Re: Giving mouse movement lag


      For those who may not know this, you can have an optional Parameter in SQL. It took me forever to figure it out.


      however not in miliseconds but 10 times slower or 10 times faster as default
      is possible

      HTH

      Michel




      "c.k." <hrsiseo@heiaow .peoschreef in bericht
      news:rbr9g4dsq2 ima2me7g6kqa4tu d47bnfqao@4ax.c om...
      >I was wondering if there was a way to give mouse movement on an empty form
      >some lag/delay? For instance, user moves mouse, and the cursor is
      20ms (possible adjustable from some option) behind the movement. So when
      user stops moving mouse, 20ms later the cursor itself stops
      moving...
      I tried using:
      Windows.Forms.C ursor.Current.P osition = New System.Drawing. Point(x,y)
      and forms of sleep/timer events but cant seem to get it to work
      correctly....
      Well anyway if anyone knows how to do it, some help would be appreciated.

      Comment

      • c.k.

        #4
        Re: Giving mouse movement lag


        Thanks for the advice, changing the mouse speed isnt quite what i want, i'd like the speed to be same, just happen x milliseconds later.
        Anyway, I wrote some code around the idea of just hiding the mouse pointer (altho in the below code it's commented out), but doesn't seem to
        want to work correctly. I'll paste the code here..just open up a big form, and add a radio button with no text (acting as a temp 'fake'
        mouse cursor):

        Public Class Form1

        Dim t As New Timer
        Dim iX(0) As Integer
        Dim iY(0) As Integer
        Dim i1 As Integer = 0
        Dim i2 As Integer = 0
        Dim tmEvent1(0) As DateTime
        Dim tmEventNow As DateTime
        Dim tmSpan As TimeSpan
        Dim tmEventMisc As DateTime

        Private Sub Form1_Click(ByV al sender As Object, _
        ByVal e As System.EventArg s) Handles Me.Click
        Me.Close()
        End Sub

        Private Sub Form1_Load(ByVa l sender As Object, _
        ByVal e As System.EventArg s) Handles Me.Load
        t.Interval = 1
        AddHandler t.Tick, AddressOf Me.MoveFakeMous e
        t.Start()
        End Sub

        Private Sub Form1_MouseEnte r(ByVal sender As Object, _
        ByVal e As System.EventArg s) Handles Me.MouseEnter
        'Cursor.Hide()
        End Sub

        Private Sub Form1_MouseLeav e(ByVal sender As Object, _
        ByVal e As System.EventArg s) Handles Me.MouseLeave
        'Cursor.Show()
        End Sub

        Private Sub Form1_MouseMove (ByVal sender As Object, _
        ByVal e As System.Windows. Forms.MouseEven tArgs) Handles Me.MouseMove
        ReDim iX(i1)
        ReDim iY(i1)
        ReDim tmEvent1(i1)
        iX(i1) = e.X
        iY(i1) = e.Y
        tmEvent1(i1) = Now
        i1 += 1
        End Sub

        Private Sub MoveFakeMouse()
        Me.Text = CStr(i1) & " " & CStr(i2) & " - X:" & CStr(iX(i2)) & _
        " Y:" & CStr(iY(i2))
        If i2 >= (tmEvent1.Count - 1) Then Exit Sub
        tmEventNow = Now
        tmEventMisc = tmEvent1(i2)
        tmSpan = tmEventNow.Subt ract(tmEventMis c)

        If tmSpan.TotalMil liseconds 20 Then
        RadioButton1.To p = iY(i2)
        RadioButton1.Le ft = iX(i2)
        i2 += 1
        End If
        End Sub

        End Class

        The idea is, Form1_MouseMove adds the current mouse coords to an array (iX, iY), and also the current time to a secondary array (tmEvent).
        And the timer, every milisecond, triggers MoveFakeMouse() . This sub then checks the time on the tmEvent array with current time and if its
        20ms difference, moves the radiobutton using the coords from the associated iX & iY arrays. Then moves on to next array and just keeps doing
        that...
        But the radiobutton doesn't seem to move, or if it does, it will only move after the mouse has stopped moving and the MoveFakeMouse has
        'caught up'. I have a me.text line in there to show it catching up and how the x/y coords dont show up til then.... Anyway, any ideas on why
        it's not working, or if i'm completely doing it wrong, another way of doing it... Just looking for a way to delay mouse movement, or have a
        fake cursor do exact same movements, just a few moments later....


        On Mon, 27 Oct 2008 00:11:00 -0700, SurturZ <surturz@newsgr oup.nospamwrote :
        >I think making the mouse invisible and then displaying a fake mouse pointer
        >would be your best bet, since you need to know where the "future" mouse will
        >be.

        Comment

        • James Hahn

          #5
          Re: Giving mouse movement lag

          Your REDIM is wiping out the values in the tables before they get processed.
          use ReDim Preserve instead.

          "c.k." <hrsiseo@heiaow .peowrote in message
          news:nqtcg4191r bs1mqlhets07d7k ok3r81r6b@4ax.c om...
          >
          Thanks for the advice, changing the mouse speed isnt quite what i want,
          i'd like the speed to be same, just happen x milliseconds later.
          Anyway, I wrote some code around the idea of just hiding the mouse pointer
          (altho in the below code it's commented out), but doesn't seem to
          want to work correctly. I'll paste the code here..just open up a big form,
          and add a radio button with no text (acting as a temp 'fake'
          mouse cursor):
          >
          Public Class Form1
          >
          Dim t As New Timer
          Dim iX(0) As Integer
          Dim iY(0) As Integer
          Dim i1 As Integer = 0
          Dim i2 As Integer = 0
          Dim tmEvent1(0) As DateTime
          Dim tmEventNow As DateTime
          Dim tmSpan As TimeSpan
          Dim tmEventMisc As DateTime
          >
          Private Sub Form1_Click(ByV al sender As Object, _
          ByVal e As System.EventArg s) Handles Me.Click
          Me.Close()
          End Sub
          >
          Private Sub Form1_Load(ByVa l sender As Object, _
          ByVal e As System.EventArg s) Handles Me.Load
          t.Interval = 1
          AddHandler t.Tick, AddressOf Me.MoveFakeMous e
          t.Start()
          End Sub
          >
          Private Sub Form1_MouseEnte r(ByVal sender As Object, _
          ByVal e As System.EventArg s) Handles Me.MouseEnter
          'Cursor.Hide()
          End Sub
          >
          Private Sub Form1_MouseLeav e(ByVal sender As Object, _
          ByVal e As System.EventArg s) Handles Me.MouseLeave
          'Cursor.Show()
          End Sub
          >
          Private Sub Form1_MouseMove (ByVal sender As Object, _
          ByVal e As System.Windows. Forms.MouseEven tArgs) Handles Me.MouseMove
          ReDim iX(i1)
          ReDim iY(i1)
          ReDim tmEvent1(i1)
          iX(i1) = e.X
          iY(i1) = e.Y
          tmEvent1(i1) = Now
          i1 += 1
          End Sub
          >
          Private Sub MoveFakeMouse()
          Me.Text = CStr(i1) & " " & CStr(i2) & " - X:" & CStr(iX(i2)) & _
          " Y:" & CStr(iY(i2))
          If i2 >= (tmEvent1.Count - 1) Then Exit Sub
          tmEventNow = Now
          tmEventMisc = tmEvent1(i2)
          tmSpan = tmEventNow.Subt ract(tmEventMis c)
          >
          If tmSpan.TotalMil liseconds 20 Then
          RadioButton1.To p = iY(i2)
          RadioButton1.Le ft = iX(i2)
          i2 += 1
          End If
          End Sub
          >
          End Class
          >
          The idea is, Form1_MouseMove adds the current mouse coords to an array
          (iX, iY), and also the current time to a secondary array (tmEvent).
          And the timer, every milisecond, triggers MoveFakeMouse() . This sub then
          checks the time on the tmEvent array with current time and if its
          20ms difference, moves the radiobutton using the coords from the
          associated iX & iY arrays. Then moves on to next array and just keeps
          doing
          that...
          But the radiobutton doesn't seem to move, or if it does, it will only move
          after the mouse has stopped moving and the MoveFakeMouse has
          'caught up'. I have a me.text line in there to show it catching up and how
          the x/y coords dont show up til then.... Anyway, any ideas on why
          it's not working, or if i'm completely doing it wrong, another way of
          doing it... Just looking for a way to delay mouse movement, or have a
          fake cursor do exact same movements, just a few moments later....
          >
          >
          On Mon, 27 Oct 2008 00:11:00 -0700, SurturZ <surturz@newsgr oup.nospam>
          wrote:
          >
          >>I think making the mouse invisible and then displaying a fake mouse
          >>pointer
          >>would be your best bet, since you need to know where the "future" mouse
          >>will
          >>be.
          >

          Comment

          • c.k.

            #6
            Re: Giving mouse movement lag


            Oh wow...not sure how I missed that. Thanks!


            On Tue, 28 Oct 2008 15:35:42 +1100, "James Hahn" <jhahn@yahoo.co mwrote:
            >Your REDIM is wiping out the values in the tables before they get processed.
            >use ReDim Preserve instead.
            >
            >"c.k." <hrsiseo@heiaow .peowrote in message
            >news:nqtcg4191 rbs1mqlhets07d7 kok3r81r6b@4ax. com...
            >>
            >Thanks for the advice, changing the mouse speed isnt quite what i want,
            >i'd like the speed to be same, just happen x milliseconds later.
            >Anyway, I wrote some code around the idea of just hiding the mouse pointer
            >(altho in the below code it's commented out), but doesn't seem to
            >want to work correctly. I'll paste the code here..just open up a big form,
            >and add a radio button with no text (acting as a temp 'fake'
            >mouse cursor):
            >>
            >Public Class Form1
            >>
            > Dim t As New Timer
            > Dim iX(0) As Integer
            > Dim iY(0) As Integer
            > Dim i1 As Integer = 0
            > Dim i2 As Integer = 0
            > Dim tmEvent1(0) As DateTime
            > Dim tmEventNow As DateTime
            > Dim tmSpan As TimeSpan
            > Dim tmEventMisc As DateTime
            >>
            > Private Sub Form1_Click(ByV al sender As Object, _
            > ByVal e As System.EventArg s) Handles Me.Click
            > Me.Close()
            > End Sub
            >>
            > Private Sub Form1_Load(ByVa l sender As Object, _
            > ByVal e As System.EventArg s) Handles Me.Load
            > t.Interval = 1
            > AddHandler t.Tick, AddressOf Me.MoveFakeMous e
            > t.Start()
            > End Sub
            >>
            > Private Sub Form1_MouseEnte r(ByVal sender As Object, _
            > ByVal e As System.EventArg s) Handles Me.MouseEnter
            > 'Cursor.Hide()
            > End Sub
            >>
            > Private Sub Form1_MouseLeav e(ByVal sender As Object, _
            > ByVal e As System.EventArg s) Handles Me.MouseLeave
            > 'Cursor.Show()
            > End Sub
            >>
            > Private Sub Form1_MouseMove (ByVal sender As Object, _
            > ByVal e As System.Windows. Forms.MouseEven tArgs) Handles Me.MouseMove
            > ReDim iX(i1)
            > ReDim iY(i1)
            > ReDim tmEvent1(i1)
            > iX(i1) = e.X
            > iY(i1) = e.Y
            > tmEvent1(i1) = Now
            > i1 += 1
            > End Sub
            >>
            > Private Sub MoveFakeMouse()
            > Me.Text = CStr(i1) & " " & CStr(i2) & " - X:" & CStr(iX(i2)) & _
            > " Y:" & CStr(iY(i2))
            > If i2 >= (tmEvent1.Count - 1) Then Exit Sub
            > tmEventNow = Now
            > tmEventMisc = tmEvent1(i2)
            > tmSpan = tmEventNow.Subt ract(tmEventMis c)
            >>
            > If tmSpan.TotalMil liseconds 20 Then
            > RadioButton1.To p = iY(i2)
            > RadioButton1.Le ft = iX(i2)
            > i2 += 1
            > End If
            > End Sub
            >>
            >End Class
            >>
            >The idea is, Form1_MouseMove adds the current mouse coords to an array
            >(iX, iY), and also the current time to a secondary array (tmEvent).
            >And the timer, every milisecond, triggers MoveFakeMouse() . This sub then
            >checks the time on the tmEvent array with current time and if its
            >20ms difference, moves the radiobutton using the coords from the
            >associated iX & iY arrays. Then moves on to next array and just keeps
            >doing
            >that...
            >But the radiobutton doesn't seem to move, or if it does, it will only move
            >after the mouse has stopped moving and the MoveFakeMouse has
            >'caught up'. I have a me.text line in there to show it catching up and how
            >the x/y coords dont show up til then.... Anyway, any ideas on why
            >it's not working, or if i'm completely doing it wrong, another way of
            >doing it... Just looking for a way to delay mouse movement, or have a
            >fake cursor do exact same movements, just a few moments later....
            >>
            >>
            >On Mon, 27 Oct 2008 00:11:00 -0700, SurturZ <surturz@newsgr oup.nospam>
            >wrote:
            >>
            >>>I think making the mouse invisible and then displaying a fake mouse
            >>>pointer
            >>>would be your best bet, since you need to know where the "future" mouse
            >>>will
            >>>be.
            >>

            Comment

            • James Hahn

              #7
              Re: Giving mouse movement lag

              Thanks for letting us know the information was useful.

              You are aware, I presume, that your real code will need to use a
              System.Collecti ons.Queue instead of an array (which will make the redim
              unnecessary).

              "c.k." <hrsiseo@heiaow .peowrote in message
              news:id9dg41rbh 9inru5pe1pk1e03 l57bpq2gh@4ax.c om...
              >
              Oh wow...not sure how I missed that. Thanks!
              >
              >

              Comment

              Working...