Hello Everyone,
I'm looking for some help with some code I have been doing recently using;
Basically i'm writing a program that moves the mouse to a location, left button down at the location and then moves the mouse to another location followed by left button up. Sort of a drag and drop but works in another program, basically a macro. I am using Cursor.Position to capture the X,Y of the mouse for both locations which is working fine.Code:Public Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Integer, ByVal dx As integer, ByVal dy As integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
I have tried using:
the above code didn't work, just basically moved the cursor from one place to the other - clicking the items but not dragging them. I replacedCode:Public Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Integer, ByVal dx As integer, ByVal dy As integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer) Public Const MOUSEEVENTF_LEFTDOWN = &H2 Public Const MOUSEEVENTF_LEFTUP = &H4 Public Const MOUSEEVENTF_MOVE = &H1 Public Sub LeftDown() mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) End Sub Public Sub LeftUp() mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) End Sub private sub DragtoLoc(start as point, dest as point) Cursor.Position = New Point(start) LeftDown() Cursor.Position = New Point(dest) LeftUp() end subwithCode:Cursor.Position = New Point(dest)Which even though has the correct X,Y of the destination location moves the mouse the the far right bottom corner of the screen. Move mouse actually drags the item as when I move the mouse it is still attached to the cursor.Code:Public Sub MoveMouse(ByVal xMove As Integer, ByVal yMove As Integer) mouse_event(MOUSEEVENTF_MOVE, xMove, yMove, 0, 0) End Sub MoveMouse(dest.X, dest.Y)
I am basically wondering am I doing anything wrong as I have been going over this piece of code for the last few days and now its driving me mad!
Thanks for your help!
Nick




Reply With Quote