GithubHelp home page GithubHelp logo

Comments (12)

post2seth avatar post2seth commented on April 28, 2024 4

i need this too, can anyone help?

from active-win.

codewaseem avatar codewaseem commented on April 28, 2024 4

Same here

from active-win.

jcpatac avatar jcpatac commented on April 28, 2024 4

I would love to have this functionality too. Can someone point us to the right direction?

from active-win.

majidbigdeli avatar majidbigdeli commented on April 28, 2024 1

Hello

You can use UI Automation in Windows

Example my code in c++ for chrome

// MathLibrary.cpp : Defines the exported functions for the DLL.
#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier
#include <AtlBase.h>
#include <UIAutomation.h>
#include <comutil.h>
#include "Chrome.h"
#pragma comment(lib, "comsuppw.lib")

BSTR chrome_geturl(HWND hwnd) {

	CoInitialize(NULL);
	CComBSTR empty(L"");
	BSTR r = empty;
	while (true)
	{
		if (!hwnd)
			break;
		if (!IsWindowVisible(hwnd))
			continue;


		CComQIPtr<IUIAutomation> uia;
		if (FAILED(uia.CoCreateInstance(CLSID_CUIAutomation)) || !uia)
			break;

		CComPtr<IUIAutomationElement> root;
		if (FAILED(uia->ElementFromHandle(hwnd, &root)) || !root)
			break;


		CComPtr<IUIAutomationCondition> condition;

		//URL's id is 0xC354, or use UIA_EditControlTypeId for 1st edit box
		uia->CreatePropertyCondition(UIA_ControlTypePropertyId,
			CComVariant(0xC354), &condition);

		//or use edit control's name instead
		//uia->CreatePropertyCondition(UIA_NamePropertyId,
		//      CComVariant(L"Address and search bar"), &condition);

		CComPtr<IUIAutomationElement> edit;
		if (FAILED(root->FindFirst(TreeScope_Descendants, condition, &edit))
			|| !edit)
			break; //maybe we don't have the right tab, continue...

		CComVariant url;
		if (FAILED(edit->GetCurrentPropertyValue(UIA_ValueValuePropertyId, &url)))
			break;
		r = url.bstrVal;
		break;
	}
	CoUninitialize();
	return (_bstr_t)r;

};


BSTR getChromeUrl(HWND hwnd)
{
	BSTR r = chrome_geturl(hwnd);
	return r;
}

from active-win.

post2seth avatar post2seth commented on April 28, 2024

from active-win.

hanselke avatar hanselke commented on April 28, 2024

it works for me on a mac. would need it to be working on windows/linux as well too. Any idea whats the issue?

from active-win.

post2seth avatar post2seth commented on April 28, 2024

from active-win.

timenox avatar timenox commented on April 28, 2024

is it working on windows and linux ???

from active-win.

tkainrad avatar tkainrad commented on April 28, 2024

There is a tool written in Go that can parse the active browser tab's URL from Chrome's session files: https://github.com/lemnos/chrome-session-dump

Presumably, this tool could be bundled within active-win, or its parsing code ported to NodeJS. This should work on both Windows and Linux. It might even work with all Chromium-based browsers.

I tested it on Linux already. Unfortunately, I don't have the time to do a PR currently. So, if anyone with some Go experience wants to take a look ;)

from active-win.

anis-dr avatar anis-dr commented on April 28, 2024

Does anyone have a solution for URLs on windows?

from active-win.

wrgoto avatar wrgoto commented on April 28, 2024

One option is to use browser extensions to append the URL to the window title, then parse it after retrieving it from active win.

from active-win.

creaz35 avatar creaz35 commented on April 28, 2024

same issue with windows 11 url is missing

from active-win.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.