j

j

  • NA
  • 2
  • 0

using P/Invoke to perform a drag&drop

Nov 5 2005 5:04 PM
Im trying to get the mouse to perform a drag and drop using only the api. I can get the mouse to move around and perform clicks for me but the challenge is the drag and drop operation. im trying to store the previous state of the mouse (*ie when it was pressed down*) and then while the previous state==mousedown start dragging and holding it down, until i get a mouse up message. but i cant get it to work correctly. here is the code im using Input[] input = new Input[ 1 ]; input[0].type = INPUT.MOUSE; input[0].mi.dx = x2; input[0].mi.dy = y2; //input[0].mi.dwFlags = MOUSEEVENTF.MOVE| MOUSEEVENTF.ABSOLUTE ; if(prev.wParam==UserActivityHook.WM_LBUTTONDOWN) { input[0].mi.dwFlags =MOUSEEVENTF.LEFTDOWN| MOUSEEVENTF.ABSOLUTE; SendInput( ( UInt32 ) input.Length, input, Marshal.SizeOf( input[ 0 ]) ); Console.WriteLine("test"); } input[0].mi.dwFlags = MOUSEEVENTF.MOVE| MOUSEEVENTF.ABSOLUTE ; SendInput( ( UInt32 ) input.Length, input, Marshal.SizeOf( input[ 0 ] ) ); Any ideas? i have been looking around online and will continue to. Thanks alot for your help.. For those who are curious im writing a macro that can record input and play it back, it has been successful, except for the above =)