I am trying to find the window handle of an HTML element using c# or c++ for a browser, but all I am able to capture is the parent browser window handle.
Is there a way to get a window handle to an element in the page?
I am trying to find the window handle of an HTML element using c# or c++ for a browser, but all I am able to capture is the parent browser window handle.
Is there a way to get a window handle to an element in the page?
No, because elements of an HTML page don't have own windows create for them.
There are couple case when windowed controls may be used - like listboxes/dropdowns/ActiveX (windowed) and sometimes IFrame - but general div
and other native HTML elements will not have window associated with them.
You can indeed find window handle for whole browser as it is regular windows app, but it probably not what you are looking for. You can't do that in JavaScript at all (as it does not have access to native Windows layer of browser) but both C# (Get window state of another process) and C++ (Get hwnd by process id c++) can get you main window handle and let you walk windows hierarchy.