Get the URL of the current (active) browser tab

Post your working scripts, libraries and tools
Thierry

Re: Get the URL of the current (active) browser tab

15 Dec 2016, 08:56

Hello
It seems it does not work properly if I have many tabs opened. It does not return the url of the current active tab.
uhuhseo

Re: Get the URL of the current (active) browser tab

13 Mar 2017, 01:50

Thanks for the code atnbueno. I have a simple implementation to get the chrome URL. What do you think?

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

anidealworld
Posts: 3
Joined: 17 Feb 2017, 13:07

Re: Get the URL of the current (active) browser tab

30 Mar 2017, 12:06

Thierry wrote:Hello
It seems it does not work properly if I have many tabs opened. It does not return the url of the current active tab.


Yes, sadly it grabs a specific tab/window and insists on returning that one instead of the currently active tab/window URL or last used.
burque505
Posts: 101
Joined: 22 Jan 2017, 19:37

Re: Get the URL of the current (active) browser tab

31 Mar 2017, 17:08

For PaleMoon 27.2.1 (32-bit) on Win7-x64, 64-bit AHK, I get ("The URL couldn't be determined"(MozillaWindowClass")).
Chrome works, reports (Chrome_WinWidget_1).
Firefox is the fastest of the one's I've tried so far, 437ms.
Interestingly, when Thunderbird is open, if you select a message with the mouse, it gives you a URL for the message and also reports MozillaWindowClass, which I guess is no surprise.
Thanks for the script!
Cardoso

Re: Get the URL of the current (active) browser tab

16 Apr 2017, 11:18

Please excuse my ignorance in this type of script, this is seeing for the first time, how can I get the data of this script in an external program, developed in vb.net, I want to capture the active url of this script. thank you.
User avatar
atnbueno
Posts: 83
Joined: 12 Oct 2013, 04:45

Re: Get the URL of the current (active) browser tab

28 May 2017, 03:48

Thierry wrote:Hello
It seems it does not work properly if I have many tabs opened. It does not return the url of the current active tab.

(Sorry for not seeing your message before)

That shouldn't happen :think: Which browser/version are you using? Are you using the script from the first page unmodified?

Cardoso wrote:Please excuse my ignorance in this type of script, this is seeing for the first time, how can I get the data of this script in an external program, developed in vb.net, I want to capture the active url of this script. thank you.

Excuse my ignorance in vb.net :) but this script uses the Microsoft Active Accessibility (MSAA) API. You can find links to the relevant Microsoft documentation in https://autohotkey.com/board/topic/7730 ... -09272012/ If you are able to understand it, you will have no problem in replicating the functionality.


Regards,
Antonio
DanielToward13
Posts: 35
Joined: 18 May 2017, 10:56

Re: Get the URL of the current (active) browser tab

29 May 2017, 06:28

Thanks atnbueno, great script. There is a bug and I don't know how to fix the problem. If I opened two Chrome windows (each with different tabs), the script works well but once I add a new blank tab and press the ^+!u then the script will return the previous active tab URL and after that it get stuck on that URL and couldn't identify the current tab URL anymore. Can this problem be solved?

I am using the script from the first page unmodified. Chrome browser version 58.0.3029.110 (64-bit)
hotkeyguy
Posts: 115
Joined: 11 Oct 2014, 12:22

Re: Get the URL of the current (active) browser tab

29 May 2017, 18:21

Hello atnbueno,

I'm looking for a way to get (additionally) the title of the page shown in the current (active) browser tab - in my case for Firefox. Any hints are highly appreciated!


Many thanks and greetings
hotkeyguy
Guest

Re: Get the URL of the current (active) browser tab

10 Sep 2017, 12:48

Hi

The problem with this lib is that its very slow once i have many (like 200) tabs opened.

Retrieving url time goes down to 1541ms on Chrome.

When i open fresh Edge browser with just one tab, the retrieval time is about 100ms.

So is there something that can be done to speed up url retrieval?
User avatar
JnLlnd
Posts: 233
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada

Re: Get the URL of the current (active) browser tab

15 Nov 2017, 18:01

Danny wrote:If anyone had this script fail with the Firefox version 50 release, here was my solution:
Just put Mozilla with the Legacy Browsers, so it uses DDE instead of ACC.

I think this worked for some time. But, now, with Firefox v56.0.2, both Modern and Legacy functions return an empty string. Could someone one of the browsers guru here investigate this code ?

Many thanks.
Author of freeware apps Quick Access Popup (http://www.quickaccesspopup.com),
FoldersPopup and CSV Buddy (http://code.jeanlalonde.ca)
User avatar
jeeswg
Posts: 2677
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Get the URL of the current (active) browser tab

15 Nov 2017, 18:51

- This quick fix is working for me.
- If your locale isn't English, you may like to try the numeric version of vAccPath that is currently commented out.
- It requires the Acc library.
- It may be that it can be simplified, I haven't looked at it in a long time.
- If the 'http://' bit is hidden, it assumes 'http://'.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
JnLlnd
Posts: 233
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada

Re: Get the URL of the current (active) browser tab

15 Nov 2017, 19:25

Thanks jeeswg. I'll look at it soon.

Just FYI, yes I'm my locale is not English (it is French-Canadian) but both functions work well with IE (legacy) or Chrome (modern). The issue is just with Firefox, AKAIK.
Author of freeware apps Quick Access Popup (http://www.quickaccesspopup.com),
FoldersPopup and CSV Buddy (http://code.jeanlalonde.ca)
User avatar
JnLlnd
Posts: 233
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada

Re: Get the URL of the current (active) browser tab

16 Nov 2017, 09:35

@jeeswg: I tried to fit your code in mine but I think our codes are based on the same source in this thread. There has been some variations/branched from the OP code in this thread and I'l a little lost ;-)

But, using the GetAddressBar(accObj, accPath:="") function as found on page 4 https://autohotkey.com/boards/viewtopic ... 48#p109548 (second piece of code in it), it made my script work again with Firefox 56.
Author of freeware apps Quick Access Popup (http://www.quickaccesspopup.com),
FoldersPopup and CSV Buddy (http://code.jeanlalonde.ca)
Bunny the Dummy

Re: Get the URL of the current (active) browser tab

16 Nov 2017, 14:08

Is there a way for it to just check every 10 seconds and write to a file the active url instead of me needing to do it with a hotkey?

I know how to write to a file just need to know how to get it to check without hotkey, i tried removing the hotkey but then it doesnt work
User avatar
JnLlnd
Posts: 233
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada

Re: Get the URL of the current (active) browser tab

16 Nov 2017, 14:31

Bunny the Dummy wrote:Is there a way for it to just check every 10 seconds and write to a file the active url instead of me needing to do it with a hotkey?

I know how to write to a file just need to know how to get it to check without hotkey, i tried removing the hotkey but then it doesnt work

This thread is about getting the URL out of the current browser. Repeating it every 10 seconds is another topic. I suggest you start an new topic for this. It could be helpful for users having anything else to execute repeatedly.
Author of freeware apps Quick Access Popup (http://www.quickaccesspopup.com),
FoldersPopup and CSV Buddy (http://code.jeanlalonde.ca)
User avatar
JnLlnd
Posts: 233
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada

Re: Get the URL of the current (active) browser tab

16 Nov 2017, 14:54

If this can help, here is my full script for getting the URL and getting the web page title. Most of the code for getting the URL comes from this thread but code formatting and variables naming were adapted to my own style.

Tested with IE 11, Chrome and Firefox 57 and Edge 40. Alt-Q to test it.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Author of freeware apps Quick Access Popup (http://www.quickaccesspopup.com),
FoldersPopup and CSV Buddy (http://code.jeanlalonde.ca)
Bunny the Dummy

Re: Get the URL of the current (active) browser tab

16 Nov 2017, 18:51

thank you for making a great script even more awesome

JnLlnd wrote:If this can help, here is my full script for getting the URL and getting the web page title. Most of the code for getting the URL comes from this thread but code formatting and variables naming were adapted to my own style.

Tested with IE 11, Chrome and Firefox 57 and Edge 40. Alt-Q to test it.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 14 guests