Solved Simulate clicking with the left mouse button
-
Good morning.
It's been a while since I started using Qt5 and C ++ for a program that will run on a Linux platform. I have a problem I do not know how to solve and ask for help. My program will only have to engage the left side of the screen while on the right side will be active a firefox window with the web page to enter lottery play.
When in the left half I click a particular button, the cursor will be placed on the web page and click on a particular area to indicate the number to play the bet. In this way I would like to automate the insertion of some hundreds of bets that my program will process for 3 times a week.
I could move the cursor to the web page, but I can not play the mouse click in that location. Is there someone who can help me? Thank you very much. -
@bvox123 Why don't you embed the web page in your app using http://doc.qt.io/qt-5/qtwebengine-index.html instead of trying to control Firefox?
To send mouse signals to other applications you would need to use system APIs as this is outside of Qt scope. -
@jsulm said in Simulate clicking with the left mouse button:
Why don't you embed the web page in your app using http://doc.qt.io/qt-5/qtwebengine-index.html instead of trying to control Firefox?
To send mouse signals to other applications you would need to use system APIs as this is outside of Qt scope.Thank you. I found a solution, but I do not really like it much.
I've installed xdotool and so I can press the button on the other application (eg, it's in 1000, 800) as follows:
QCursor :: setPos (1000, 800);
System ("xdotool click 1");
If anyone could suggest me a more elegant method, maybe using Qt classes, I would be really grateful.
Greetings
bvox -
Italian version of the question: https://forum.qt.io/topic/81355/simulare-il-click-del-mouse-su-un-altra-applicazione
My answer is 100% google translatable with no loss of menaing
-
@bvox123 Again: why don't you embed this web-site into your app using http://doc.qt.io/qt-5/qtwebengine-index.html ?