There is a certain application which, when launched, draws a form for entering a login and password, (conditionally: two text fields for entering text, the connect button).
With the help of win api, you can find descriptors of this window and transfer the necessary values to the fields for entering text, press the "connect" key. This is done easily using the win api FindWindow (ex) and SendMessage and other macros.
Essence of the question:
How to track the moment of rendering the data entry form and understand when my program should enter the login and password? The application is loaded for a long time in the background, a minute or three, i.e. salary time varies. Only after drawing the input window can I transfer the necessary data.
The most primitive solution that comes to my mind is to use a timer:
#include <iostream> #include <time.h> using namespace std; int main() { cout << "делай раз\n"; sleep(180000); cout << "делай два\n"; return 0; }` UPD
#include <iostream> #include <string> #include <vector> #include <windows.h> using namespace std; vector<string> WinNames; BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) { char str[255]; if (GetWindowText(hwnd, str, 255)) { if (IsWindowVisible(hwnd) && (!GetWindow(hwnd, GW_OWNER))) { string s(str); WinNames.push_back(s); } } return 1; } int main() { setlocale(LC_ALL,"Rus"); EnumWindows(&EnumWindowsProc, 0); ostream_iterator<string> out(cout,"\n"); copy(WinNames.begin(),WinNames.end(),out); system("pause"); return 0; }
#include <iostream> #include <string> #include <vector> #include <windows.h> using namespace std; vector<string> WinNames; BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) {char str[255]; if (GetWindowText(hwnd, str, 255)) { if (IsWindowVisible(hwnd) && (!GetWindow(hwnd, GW_OWNER))) {string s(str); WinNames.push_back(s);}} return 1;} int main() {setlocale(LC_ALL,"Rus"); EnumWindows(&EnumWindowsProc, 0); ostream_iterator<string> out(cout,"\n"); copy(WinNames.begin(),WinNames.end(),out); system("pause"); return 0;}#include <iostream> #include <string> #include <vector> #include <windows.h> using namespace std; vector<string> WinNames; BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) {char str[255]; if (GetWindowText(hwnd, str, 255)) { if (IsWindowVisible(hwnd) && (!GetWindow(hwnd, GW_OWNER))) {string s(str); WinNames.push_back(s);}} return 1;} int main() {setlocale(LC_ALL,"Rus"); EnumWindows(&EnumWindowsProc, 0); ostream_iterator<string> out(cout,"\n"); copy(WinNames.begin(),WinNames.end(),out); system("pause"); return 0;}- IronZeshadow