0

I'm wondering if there's any way for a Windows desktop application (i.e. compiled using the Windows SDK) to get the current URL for a browser window running in another process.

Put another way, I'm wondering if there's an equivalent method in Windows to using AppleScript / Apple events in macOS:

tell application "Chrome" to get the URL of the active tab of front window

I'm working in C++ but since the underlying API is the Windows SDK, I'm open to other languages too such as C#.

I'd love a general approach that works for Chromium-based browsers like the above AppleScript example in macOS, but if need be I'll implement different methods for each web browser I want to support.

2
  • Your question is too generic. Each web browser works different internally so you may need to implement for each a slightly different way. For easier development you can check script tools like AutoIt - they can extract text infk from other processes. Commented Nov 14, 2024 at 22:07
  • @Robert I've edited my question to make it more clear what I'm looking for. If need be I'll implement different solutions for each web browser I want to support. Commented Nov 15, 2024 at 0:55

1 Answer 1

0

I do not think that there is any such kind of API on Windows and if there was, it would probably only work with Microsoft Edge.

This kind of functionality is usually implemented in the form of a browser extension. The browser extension has access to the current state of the browser and can communicate with other applications on the system, e.g., by opening a socket.

For example, the literature management system Zotero implements it this way. Their browser extension sends the currently viewed website to the desktop application in order to insert it into its database. Their desktop client and browser extensions are open-source, so you can go and check the details of their implementation.

Of course, the downside of this approach is that you have to tell users to trust and install your browser extension. But the upside is privacy for the user.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.