How to make the mouse cursor independently produced a click? And I also need to be able to click outside the application form.
- one> eclipse delphi java visual-studio You still have to decide what language to start with. - Nofate ♦
- @Nofate is more interested in delphi and visual studio. - ivan89
|
3 answers
on c ++, through windows.h, something like this (QT, although I don’t think it will be much different in java)
//кликаем void Simulation::click() { INPUT *buffer = new INPUT[1]; buffer->type = INPUT_MOUSE; buffer->mi.dx = 0; buffer->mi.dy = 0; buffer->mi.mouseData = 0; buffer->mi.dwFlags = MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP; buffer->mi.time = 0; buffer->mi.dwExtraInfo = 0; SendInput(1,buffer,sizeof(INPUT)); delete buffer; }
- @majatu, i.e. #include windows.h needs to be done. Can you explain what type INPUT is and what mi is, SendInput? - ivan89
- I did #include <qt_windows.h> - vlukham
- it’s rather a matter of not the language, but the platform on which you click, because this is a system function - vlukham
|
Use the standard Robot class in java there you can move to click on the mouse as well as on the keyboard in and out of the program as if a virtual person is sitting in front of the computer.
|
so that the mouse cursor independently produces a click *
in delphi there is a mouse event method Mouse_Event
try experimenting, changing parameters, the following code
var pnt: TPoint; ... begin pnt.X:= random(1024); pnt.Y:= random(768); SetCursorPos(pnt.X, pnt.Y); Mouse_Event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTDOWN, pnt.x, pnt.y, 0, 0); ...
|