How to Use mouse_event() to similate mouse events?



How to Use mouse_event() to similate mouse events?..

Answer / Navneet Kuamr

In Delphi, you can use the `mouse_event` WinAPI function to simulate mouse events. Here's a simple example of how to create a click event at a specific position:nn```delphinfunction SimulateClick(x, y: Integer): Boolean;nbeginn if not System.IOUtils.TPlatformUtils.IsWinNT thenn Exit(False);n end;nn Declare function mouse_event Lib 'user32' (dwFlags: DWORD; dwX: DWORD; dwY: DWORD; dwData: DWORD; dwExtraInfo: DWORD); stdcall;nn constn MOUSEEVENTF_LEFTDOWN = $0002;n MOUSEEVENTF_LEFTUP = $0004;nn mouse_event(MOUSEEVENTF_LEFTDOWN or MOUSEEVENTF_ABSOLUTE, x, y, 0, 0);n Sleep(100);n mouse_event(MOUSEEVENTF_LEFTUP or MOUSEEVENTF_ABSOLUTE, x, y, 0, 0);nend;n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Delphi Interview Questions

How to place a bitmap in a Metafile?

1 Answers  


How to create an executible file using the command line directive in Linux with Kylix?

1 Answers  


what is Auto increment Build Number?

1 Answers  


How to Change windows default printer in code?

1 Answers  


Where is proxies.dcu?

1 Answers  


How to use return instead of tab or mouse to move off a control ?

1 Answers  


How to get a list of CDROM drives on a computer?

1 Answers  


Explain the MasterSource/MasterFields behavior?

1 Answers  


How to Get property information ?

1 Answers  


How to Detect if the system time has been changed ?

1 Answers  


How to Save and load metafiles in a BLOB field without using DBImage ?

1 Answers  


How to Calculatea point using angles and distance?

1 Answers  


Categories