Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Get the URL of the current (active) browser tab


  • Please log in to reply
34 replies to this topic
Kipp
  • Members
  • 4 posts
  • Last active: Oct 22 2014 12:50 PM
  • Joined: 10 Mar 2013

Really nice code.  Thanks for sharing.

 

While testing the code out unmodified I was getting run-time errors on lines 63, 65 and 70.  It was remedied by adding Try in front of each statement.

	Try sURL := accAddressBar.accValue(0)
	If (sURL == "") {
		Try sURL := accAddressBar.accDescription(0) ; Origin Chip support
		If (sURL == "") {
			WinGet, nWindows, List, % "ahk_class " sClass ; In case of a nested browser window as in CoolNovo
			If (nWindows > 1) {
				accAddressBar := GetAddressBar(Acc_ObjectFromWindow(nWindows2))
				Try sURL := accAddressBar.accValue(0)
			}
		}
	}



av930
  • Members
  • 4 posts
  • Last active: Feb 07 2018 07:47 AM
  • Joined: 22 Aug 2012

Hello Atnbueno. I am still new to AHK.

 

I found your script and tried to use it within my browser.

but it doesn't work.

 

I downloaded GetActiveBrowserURL.ahk and Acc.ahk in one directory

and run it. but it make some error

 

>>>Line Text: Try SURL : accAddress3ar.accValue©

>>> Error: ThlS llne does not contaln a recognlzed act-on.

>>> The program Will exit.

 

if I run Acc.ahk

 

>>> Error: This  does not contian a recognized action.

>>> Specifically: try return

>>> ComObjType(Acc " Name")="IAcceSSlble"?Acc_GetRoleText(Acc.accRole(ChildId)) :"invlalid object...

>>> Line

>>> 065- Return DllCall (SetWinEventHook" "Lint" eventMin, "Uint"

>>> eventMax, "Ulnt" 0 Ptr, pCallback, "Ulnt" 0 "l_llnt" 0 "l_llnt" 0)

>>> 066:}

>>> 070: Return,D Call(" nEvent" "Ptr" hHook)

>>> 071:}

>>> The program Will exit.

 

 

please give me direction. 
 

what I am finally trying to is this:

1. press specific key "Ctrl +#" on a browser like IE, Chrome, Firefox, Maxthon 

2. if I press "Ctrl+1", get the url from current browser run the url on IE.

3. if I press "Ctrl+2", get the url from current browser run the url on Chrome.

4. if I press "Ctrl+3", get the url from current browser run the url on Firefox.

5. if I press "Ctrl+4", get the url from current browser run the url on Maxthon .

 

Please help me.
I am sick of switching my several browser and IE ActiveX and misc problem..

 

av9300 at gmail.com  from Korea.

 

 



DigiDon
  • Members
  • 9 posts
  • Last active: Jan 10 2016 01:30 PM
  • Joined: 28 Feb 2014

Hi atnbueno !

 

I want to thank you for this great function !

I implemented it my new sotware version based on recognition of current window and it made it even more capable !

 

I wonder if it recognized Windows 10 Edge internet explorer as a web browser and if it is working with it normally though?

Can you confirm it is working or should I take a deeper look ? (I will have to install a virtual machine if so cause I'm staying on 7)

 

Once again thank you very much.

I will write down that I need to give you a key to my software when the new version will be done.

 

It allows very fast note creation and access on any Program/file/folder/window and now websites and webpages thanks to you ! :)

 

Cheers!



robertmarkbram
  • Members
  • 48 posts
  • Last active: Mar 25 2018 02:25 AM
  • Joined: 07 Oct 2010

This is only working half the time for me.. It works a few times in a row and then endlessly reports 

 

The URL couldn't be determined (Chrome_WidgetWin_1)
 
Is there some sort of timing think that I can put a wait in?
 
I am not having a good day with AHK today. :(
 
Rob
:)


atnbueno
  • Members
  • 91 posts
  • Last active: Feb 16 2016 07:04 PM
  • Joined: 24 Mar 2007

Hello again.

It's been more than a year (!), so it's time for an updated version in the OP:
- Now it works with Microsoft Edge (only tested via VM) and Slimjet (both suggestions by Kudos)
- Better URL detection (thanks LarryC for the feedback)
- Added workaround for runtime errors suggested by Kipp a year ago
- Removed support for Google's failed Origin Chip experiment

 

And a couple of better-late-than-never :p answers:

 

@av930: You don't need acc.ahk (I included the required required functions in my script) and your problems are probably fixed in the updated version. About your "Open in..." script, you almost have it written :) Review my example of use (#u:: ...) and use Run instead of MsgBox.

 

@DigiDon: I've only been able to test Windows 10 in a VM, but Edge works with the updated version. I've been told by Kudos that sometimes it doesn't work, so I'll have to do additional testing once I get my hands in a non-virtualized Win10. And your program sounds really useful. I'm glad this code helped.

 

@robertmarkbram: No, there is no step in the process that you can improve by adding delays. And I'm sorry but I have not been able to reproduce your problem, so I can't offer any idea to test.

 

 

Regards from Spain,

Antonio

 

 

EDIT 2015-10-29: I've had an idea of what may be happening to Rob, but I need to test it. Rob, please coment out line 58 (just the one, leave the braces as they are) and see if your experience improves.

 

EDIT 2015-12-31: This board will be read-only from now on. Development of this script will continue in the new board: https://autohotkey.c...opic.php?t=3702