FastRodas Posted April 20, 2004 Posted April 20, 2004 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 Quote
Leaders Iceplug Posted April 20, 2004 Leaders Posted April 20, 2004 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. :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Leaders snarfblam Posted April 21, 2004 Leaders Posted April 21, 2004 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! Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.