Get the address bar url from a browser

I would like to know how can I get the url from the address bar in a browser, I would like to do it preferably in the most popular browsers like firefox, chrome, edge, opera etc.

The code from this snswer from stack overflow answer https://stackoverflow.com/a/19296923/11337328 does what I want but only works for Internet Explorer, I don't understand the code, how it is getting that info though.

If someone knows how can I do that for other browsers please help. Thank you.
Is this a Windows specific question? If so, please move it to the Windows Programming section.
It goes both to windows and linux. But I will post it on indows Programming section to see if I get the answer for the windows side.
https://www.selenium.dev/documentation/en/webdriver/
Good news - it supports all browsers and is cross-platform.
Bad news - it doesn't have a C++ binding (or maybe it does https://github.com/durdyev/webdriverxx )
Last edited on
That code finds the windows according to their name and the structure (i.e. what wndow has what child).

So if you knew the names and structure of the windows of firefox etc. you could do the same for them.
most browsers have some sort of plugin interface and there should be a way to tap the data you need from it: that seems like a very basic piece of info.

trying to back-hack the gui to steal a piece of info is difficult and aggravating; it is a last resort that is bug prone (updates to the browser can break your code) and can even trigger some anti virus etc.
@salem c
The webdriverxx always throws an expcetion( what() : Cannot perform HTTP request (result: 7, message: Failed to connect to localhost port 4444: Connection refused )
And still, by looking at some of its code examples I couldn't understand how that would help on my problem.
@coder777 Any idea on how I would get those names. I tried Spy++ but could figure out how it works.
Topic archived. No new replies allowed.