Get the URL of the current (active) browser tab

Post your working scripts, libraries and tools
User avatar
JnLlnd
Posts: 305
Joined: 29 Sep 2013, 21:29
GitHub: JnLlnd
Location: Montreal, Quebec, Canada
Contact:

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

05 Aug 2018, 16:14

AHKStudent wrote:in chrome 67 and 68 if you have a new tab window as the main window this wont work

to test click to get a new tab in chrome and then run to get list of windows, u will get blank even if you have 5 other regular websites opne
@AHKStudent: If we are talking of the same function GetActiveBrowserURL(), this function retrieves the active tab's URL. What you describe is not an error since there is no URL to retrieve in a blank tab.

@atnbueno: I hope you or another wizard here will be able to look into the Firefox issue...
Author of freeware apps Quick Access Popup (http://www.quickaccesspopup.com),
FoldersPopup and CSV Buddy (http://code.jeanlalonde.ca)
Johnny R
Posts: 277
Joined: 03 Oct 2013, 02:07

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

09 Aug 2018, 02:35

No atnbueno, no solution. Where is atnbueno?
Johnny R
Posts: 277
Joined: 03 Oct 2013, 02:07

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

18 Aug 2018, 08:09

I've reinstalled the newest version of the script and the problem was solved. The script works fine with Firefox v61.0.2. Thank You all!
User avatar
JnLlnd
Posts: 305
Joined: 29 Sep 2013, 21:29
GitHub: JnLlnd
Location: Montreal, Quebec, Canada
Contact:

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

19 Aug 2018, 13:22

I confirm. This works with Firefox v61.0.2:
https://autohotkey.com/boards/viewtopic ... 81#p182981
Author of freeware apps Quick Access Popup (http://www.quickaccesspopup.com),
FoldersPopup and CSV Buddy (http://code.jeanlalonde.ca)
hotkeyguy
Posts: 147
Joined: 11 Oct 2014, 12:22

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

22 Oct 2018, 08:20

I'm using JnLlnds code. With Firefox 62.0.3, I get sometimes two error messages
1. An error occurred in the secure channel support
followed by
2. The data necessary to complete this operation is not yet available.

The affected lines are objWebRequest.Send() ; and return (objWebRequest.StatusText() = "OK" ? objWebRequest.ResponseText() : "") in function Url2Var(strUrl):

Code: Select all

;------------------------------------------------------------
Url2Var(strUrl)
;------------------------------------------------------------
{
	objWebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
	/*
	if (A_LastError)
		; an error occurred during ComObjCreate (A_LastError probably is E_UNEXPECTED = -2147418113 #0x8000FFFFL)
		BUT DO NOT ABORT because the following commands will be executed even if an error occurred in ComObjCreate (!)
	*/
	objWebRequest.Open("GET", strUrl)
	objWebRequest.Send() ; <== ERROR 1

	return (objWebRequest.StatusText() = "OK" ? objWebRequest.ResponseText() : "") ; <== ERROR 2
}
;------------------------------------------------------------
That happens e. g. with GitHub pages, like GitHub - nshalabi/SysmonTools: Utilities for Sysmon.
I assume that's an certificate validation issue? I tried Sleep instructions without success.


Many thanks for all your efforts and any hints
hotkeyguy
User avatar
JnLlnd
Posts: 305
Joined: 29 Sep 2013, 21:29
GitHub: JnLlnd
Location: Montreal, Quebec, Canada
Contact:

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

22 Oct 2018, 08:41

Hi,

> I'm using JnLlnds code. With Firefox 62.0.3, I get sometimes two error messages

I tried only a few times but it worked with the same Firefox version.

BTW, I worked on in but I'm not the one who wrote the "core" of the code. It is from atnbueno.

Jean
Author of freeware apps Quick Access Popup (http://www.quickaccesspopup.com),
FoldersPopup and CSV Buddy (http://code.jeanlalonde.ca)
freespacing
Posts: 131
Joined: 28 Sep 2016, 11:14
Contact:

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

21 Feb 2019, 09:43

Spanish version just because…
¡Hola atnbueno!
Gracias por el post con todo lujo de detalles.
Por casualidad ¿tendrías alguna sugerencia para Pale Moon?
De costumbre lo hago con JS dentro de Dorando o GreaseMonkey, pero me resultaría sumamente útil hacerlo en ahk.
Gracias y hasta pronto.

English because that's this board's language
Hello atnbueno!
Thanks for the post full of details.
Do you by any chance have any suggestions for Pale Moon?
I usually do it with JS inside Dorando or GreaseMonkey, but it would be extremely useful to do it in ahk.
Dest938572
Posts: 3
Joined: 28 Dec 2015, 06:02

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

02 Jul 2019, 08:36

atnbueno wrote:
08 Jun 2014, 13:19

Short version: The code below finds out the URL of the current (active) browser tab for most of the modern browsers.
Awesome script, thank you Antonio.
It works perfect more than 5 years.
The shape and solutions of the future depend totally on the collective effort of all people working together.
© Jacque Fresco
tdalon
Posts: 11
Joined: 21 Apr 2017, 07:19
Google: thierrydalon
GitHub: tdalon

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

18 Nov 2019, 04:00

Hi Antonio
I have noticed an issue (Win10) with Internet Explorer.
If I have multiple windows opened, it returns the url of the first opened window and not the one where I have the focus on.
Last edited by tdalon on 13 Feb 2020, 09:55, edited 1 time in total.
tdalon
Posts: 11
Joined: 21 Apr 2017, 07:19
Google: thierrydalon
GitHub: tdalon

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

13 Feb 2020, 09:51

Would be great if it could support Vivaldi.
My workaround is to have:

Code: Select all

If WinActive("ahk_exe vivaldi.exe") {
		Send ^l
		sURL := GetSelection()
		return sURL
		Send {Esc}
	}
I forgot to post:

Code: Select all

GetSelection(){
; Syntax:
; 	sSelection:=GetSelection()


OldClipboard:= ClipboardAll                         ;Save existing clipboard.

Clipboard:=""
while(Clipboard){
  Sleep,10
}
Send,^c                                          ;Copy selected text to clipboard
ClipWait
  sSelection := clipboard

; Restore Clipboard
Clipboard:= OldClipboard 
return sSelection
} 
Last edited by tdalon on 15 Feb 2020, 14:59, edited 1 time in total.
rommmcek
Posts: 863
Joined: 15 Aug 2014, 15:18

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

14 Feb 2020, 10:39

Recently is saw this beautiful way, I use often too.
If you still have problems just repost!
garry
Posts: 2026
Joined: 22 Dec 2013, 12:50

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

14 Feb 2020, 15:54

rommmcek, thank you , and I used ctr+l for firefox and chrome ( maybe also for other browsers ( ? ) )
rommmcek
Posts: 863
Joined: 15 Aug 2014, 15:18

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

14 Feb 2020, 17:45

@garry: AFAIK we have already history... For FF works ^l as well as !d. For most browsers does, although the first one seems to be more universal.
garry
Posts: 2026
Joined: 22 Dec 2013, 12:50

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

15 Feb 2020, 10:14

for firefox also alt+s

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 25 guests