W
W
WenSiL2019-05-13 18:53:38
Google Chrome
WenSiL, 2019-05-13 18:53:38

How to click a button in chrome via WinAPI?

It is necessary to press a specific key combination in a specific browser tab, but I ran into 2 problems:
1) How to get the HWND of exactly the open tab?
2) How to correctly send a message tab?
Wrote a simple program:

#include<stdio.h>
#include<windows.h>

int main() {
    for(;;Sleep(500)) {
        POINT CursorPos;
        GetCursorPos(&CursorPos);
        int hwnd = WindowFromPoint(CursorPos);	
        SendMessage(hwnd, WM_KEYDOWN, VK_LSHIFT, 0);   
    }
    return 0;
}

And, it seems, the handle is correct, but the messages do not reach the tab.
Maybe someone knows how to search for tabs in chrome and how to send messages to them correctly?
Or maybe there are some other ways to achieve the goal, but always in C++?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question