Click the button in other application using QT
-
Hi
I would try with https://www.autoitscript.com/site/
and if it cant push the button. Nothing can. -
I try with:
#include "mainwindow.h" #include "ui_mainwindow.h" #include "windows.h" #include <QDebug> BOOL CALLBACK EnumChildProc ( HWND hwndChild, LPARAM lParam) { qDebug() << "tmp message"; return TRUE; } MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); HWND hWndParent = FindWindow( NULL, L"abcde" ); qDebug() << "address" << hWndParent; EnumChildWindows( hWndParent, EnumChildProc, NULL ); } MainWindow::~MainWindow() { delete ui; }
but with no positive result ( I don't see any child of "abcde" ).
qDebug from hWndParent is good - I get it, but no his childs ( I don't see any "tmp message" ).
-
I try with:
#include "mainwindow.h" #include "ui_mainwindow.h" #include "windows.h" #include <QDebug> BOOL CALLBACK EnumChildProc ( HWND hwndChild, LPARAM lParam) { qDebug() << "tmp message"; return TRUE; } MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); HWND hWndParent = FindWindow( NULL, L"abcde" ); qDebug() << "address" << hWndParent; EnumChildWindows( hWndParent, EnumChildProc, NULL ); } MainWindow::~MainWindow() { delete ui; }
but with no positive result ( I don't see any child of "abcde" ).
qDebug from hWndParent is good - I get it, but no his childs ( I don't see any "tmp message" ).
@TomNow99
Hi
is that a QPushbutton ?You have to understand if the control/button is not a native windows control, it wont have a handle and
wont show up with EnumChildWindowsSo its not really easy to automate a Qt app from outside for instance.
-
Sometimes I would like to automate some GUI application which often don't have native windows controls. I know that some app I can control from QT ( for example excel ), but I think ( for example ) about apps to sell in a shop too, which are custom by owners of the shop.
-
Sometimes I would like to automate some GUI application which often don't have native windows controls. I know that some app I can control from QT ( for example excel ), but I think ( for example ) about apps to sell in a shop too, which are custom by owners of the shop.
@TomNow99
Well for custom widgets, you cannot use win API for it.
Then you would have to hand code something that moves mouse to button and clicks.Browsers have anti measure for this so that dont often work.
But for other apps it will.- which are custom by owners of the shop.
So thats inside a browser ?
- which are custom by owners of the shop.
-
@mrjj Now I think about Desktop apps.
I thought about move mouse to button and click too. But how can I do this? Do you think about: open that dekstop app, check (x,y) mouse's position and write app to simulate clicking in this place? This is solution, but I think it is very bad. Do you know better?
-
@mrjj Now I think about Desktop apps.
I thought about move mouse to button and click too. But how can I do this? Do you think about: open that dekstop app, check (x,y) mouse's position and write app to simulate clicking in this place? This is solution, but I think it is very bad. Do you know better?
@TomNow99
Hi
In Qt you can use QCursor to move mouse around.I used autoit and https://www.autoitscript.com/forum/files/file/471-image-search-udf/
to search for the button with image so if window was moved then it would still find it.
Its not a nice solution but i never found anything better. -
-
@mrjj Thank you. I checked QCursor and it's work perfect. Can you tell me how Can I click using Qt?
I would like to move mouse cursor using QCursor and when cursor is above some icon with exe I would like to double click on this icon and run an exe.