get-windows icon indicating copy to clipboard operation
get-windows copied to clipboard

need to get browser's active tab url for windows and linux

Open dsoftware763 opened this issue 5 years ago • 14 comments

can anyone help me to add this feature

dsoftware763 avatar Feb 21 '20 12:02 dsoftware763

i need this too, can anyone help?

post2seth avatar Apr 25 '20 07:04 post2seth

Same here

codewaseem avatar May 25 '20 13:05 codewaseem

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

jcpatac avatar Jun 01 '20 09:06 jcpatac

Does someone got success on Mac as I tried but on Mac I don’t even get the URLs as mentioned in description.

On Mon, 1 Jun 2020 at 3:18 PM, John Caesar Patac [email protected] wrote:

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

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sindresorhus/active-win/issues/64#issuecomment-636746988, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWQG4HNV7QNXPUZ5FTBTULRUN2PHANCNFSM4KZCLYCQ .

-- Sent from Gmail iPhone App

post2seth avatar Jun 01 '20 10:06 post2seth

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

hanselke avatar Jun 04 '20 07:06 hanselke

No idea, but documentation already described its not working on windows and Linux. I saw the code and it’s for Mac only but somehow at my Mac machine it was not working.

I found privacy settings I think I have to permit that to grab the url on Mac. Will update you if that’s working.

On Thu, 4 Jun 2020 at 12:55 PM, hansel [email protected] wrote:

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

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sindresorhus/active-win/issues/64#issuecomment-638657956, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWQG4GEVI6N6VGRCR4VFWDRU5D5VANCNFSM4KZCLYCQ .

-- Sent from Gmail iPhone App

post2seth avatar Jun 04 '20 07:06 post2seth

is it working on windows and linux ???

timenox avatar Jul 26 '20 13:07 timenox

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 ;)

tkainrad avatar Jan 29 '22 07:01 tkainrad

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;
}

majidbigdeli avatar Jan 29 '22 19:01 majidbigdeli

Does anyone have a solution for URLs on windows?

anis-dr avatar Apr 08 '22 01:04 anis-dr

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

wrgoto avatar Apr 13 '22 22:04 wrgoto

same issue with windows 11 url is missing

creaz35 avatar Jun 08 '22 09:06 creaz35