Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi to all xtremers,

 

i am playing a little with vb.net in vs.net and i wanted to make the mouse mouse from one place to another, and drag some items around. So i made a simple form and added a button that when clicked moves the mouse. But it does not do it correctly. My code is this

 

Public Structure POINTAPI

Dim x As Int32

Dim y As Int32

End Structure

 

Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

 

Public Const MOUSEEVENTF_LEFTDOWN = &H2

Public Const MOUSEEVENTF_LEFTUP = &H4

Public Const MOUSEEVENTF_MIDDLEDOWN = &H20

Public Const MOUSEEVENTF_MIDDLEUP = &H40

Public Const MOUSEEVENTF_RIGHTDOWN = &H8

Public Const MOUSEEVENTF_RIGHTUP = &H10

Public Const MOUSEEVENTF_MOVE = &H1

 

 

Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command1.Click

 

mouse_event(MOUSEEVENTF_MOVE, 300, 400, 0, 0)

mouse_event(MOUSEEVENTF_MOVE, 700, 300, 0, 0)

mouse_event(MOUSEEVENTF_MOVE, 40, 800, 0, 0)

End Sub

 

Ok here it is..

 

my problem is that the y coordenates are not being assumed. It looks like that y is always zero and can only more through the x coordenates

 

can anyone tell me whats wrong?

 

thx to all

  • Leaders
Posted
The first thing that jumps out at me is that you are using 64-bit longs in a Win32 API ;). You should be using Integers (Int32s) instead of Longs. Also, the constants need to be declared as Integers also. :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

  • Leaders
Posted
The first thing that jumps out at me is that you are using 64-bit longs in a Win32 API . You should be using Integers (Int32s) instead of Longs. Also, the constants need to be declared as Integers also.

 

The reason for that is probably that this is a declaration for VB6. When declaring Windows API functions, you should always be careful that you are using the right data types. If the declaration is written for VB6, you must change longs to ints!

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...