Modeling drag and drop in Delphi

I have a Delphi form and it has TWebbroser with a google map on it. I want to simulate a mouse. Left click, move the mouse to another position, release the mouse. He must drag the map from left to right. I tried this, but the map is not draggable.

procedure MoveMouse (X,Y,Speed: Integer); var Maus : TPoint; mx, my, nx, ny, len : double; begin mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); if Speed < 1 then Speed := 1; GetCursorPos(Maus); mx := maus.x; my := maus.y; While (mx<>x)OR(my<>y) Do begin nx := x-mx; ny := y-my; len := sqrt(nx*nx + ny*ny); if(len<=1)Then begin mx:=x; my:=y; end else begin nx := nx / (len*0.5); ny := ny / (len*0.5); mx := mx + nx; my := my + ny; end; Mouse_Event(MOUSEEVENTF_ABSOLUTE, Round(mx)+50,Round(my), 0, GetMessageExtraInfo); // SetCursorPos(Round(mx),Round(my)); Sleep(Speed); end; mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); end; 

Please help me? Thank you very much!

+4
source share

Source: https://habr.com/ru/post/1482200/


All Articles