I Am Using VB.NET 2008 Express Edition, and am trying to make a program that controls the mouse position with a joystick on the a nintendo classic controller, which returns a value between [ -.54 ] and [ +.54 ].

I wanted so that the position vertically of the mouse on the screen = vertical position on the screen + (joystickvalue * 100)

I have searched many forums and still can not find an answer on how to set the cursor position.

i have found e.location.x that says it is a reador wright variable, but when i set it equal to a number i get an error saying
"Expression is a value and therefore cannot be the target of an assignment."

Any Help Is Greatly Appreciated
Thanks
~Matt

i have found e.location.x that says it is a reador wright variable, but when i set it equal to a number i get an error saying
"Expression is a value and therefore cannot be the target of an assignment."

What event are you trapping? For example

Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
  ' This gives an error since e.Location is read-only
  e.Location = New Point(0, 0)

End Sub

would give an error.

You should actually set the cursor position, not the mouse position. Drop a button to a form and try the following code

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  ' Button click sets mouse position to upper left corner (x=0, y=0) of the form
  Dim NewPos As Point

  ' New coordinates
  NewPos.X = 0
  NewPos.Y = 0
  ' Use form coornidates (PointToClient() would use screen coordinates i.e.
  ' NewPos = PointClient(NewPos) would set the cursor to the upper left corner of the screen)
  NewPos = PointToScreen(NewPos)
  ' Move (mouse)cursor
  Cursor.Position = NewPos

End Sub

I hope this gets you started.

i keep getting this error on line 10 and 12 on the NewPos part.

Value of type 'WiimoteLib.Point' cannot be converted to 'System.Drawing.Point'.

and i want this to be under a wiimote statechange event if that is what you are asking.

Private Sub State_Change(ByVal sender As Object, ByVal wm As WiimoteChangedEventArgs)

    End Sub

Ok. My example was for the windows forms. I'm not familiar with Wii and programming it. But the basic idea could be the same with Wii. I can't be 100% sure of that. Maybe simply replacing Dim NewPos As Point with Dim NewPos As WiimoteLib.Point works. You could also try DirectCast(NewPos, System.Drawing.Point) or DirectCast(NewPos, WiimoteLib.Point) depending on which coordinate system you need.

i want this to be under a wiimote statechange event if that is what you are asking.

Yes, I asked that. There's no problem if you get current mouse coordinates or the location information from ByVal wm As WiimoteChangedEventArgs argument (you'll need that in your calculation).

If you still can't set the mouse location, I suggest to keep searching in Wii/Nintendo forums. BTW, are you creating a winforms app or something for Wii/Nintendo?

Ok thanks, ill try that, and a winforms app. Im 16, not working for Nintendo Yet =p

not working for Nintendo Yet =p

I guessed that ;) I just phrased my words in an incorrect way. English is not my native language :)

English is not my native language :)

Still pretty good though =p

the new code works awesome, but i still have one more question,
simulating mouse clicks
i have found threads explaining how do it in about 30 lines of code and does not work for me, and i know that there has to be something easier then that =)

simulating mouse clicks

You can call mouse click handlers

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  '
  Dim MouseArgs As System.Windows.Forms.MouseEventArgs

  MouseArgs = New System.Windows.Forms.MouseEventArgs(Windows.Forms.MouseButtons.Left, 1, 100, 100, 0)
  Form1_MouseClick(sender, MouseArgs)
  ' Or
  'Form1_MouseClick(Me, MouseArgs)

End Sub

Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
  ' Handle mouse click on the form

End Sub

from the code if this is what you mean by "simulating mouse click". If not, I suggest starting a new thread since that's a totally different question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.