Link: GetAccData() v6.45 - function to retrieve Title and Url of the desired browser tab
(This is fork of atnbueno's GetActiveBrowserURL() function.)
Special thanks to malcev for the improvement of the initializing the Acc and buffering the AccObj for IE and Vivaldi.
Get Title and Url of the active browser tab
Get Title and Url of the active browser tab
Last edited by rommmcek on 10 Apr 2021, 10:16, edited 13 times in total.
Re: Get Title and Url of the desired browser tab
The coloring & sizing of your link make it kinda challenging to spot it as one. JM2€C
Re: Get Title and Url of the active browser tab
I get an error on Firefox 84.0.1 (64-bit); Windows 10, Version 10.0.19041.685 twice when I try to get the URL, works in Chrome though. (atnbueno's hasn't worked for me with Firefox for a long time either)
Code: Select all
---------------------------
GetAccData.ahk
---------------------------
Error: 0x80004003 - Invalid pointer
Source: (null)
Description: (null)
HelpFile: (null)
HelpContext: 0
Specifically: accName
Line#
017: accRR := ""
017: accData := ""
018: nWin:= WinExist(WinId), ParseAccData( GetAccObjectFromWindow(nWin) )
019: }
021: {
023: if !accRR
023: {
---> 024: accData? "": accData:= [accObj.accName(0)]
025: Try
025: if accObj.accName(0) && accObj.accValue(0) && accObj.accRole(0) = 42
026: accData.2:= SubStr(u:=accObj.accValue(0), 1, 4)="http"? u: "http://" u, accRR:= 1
027: For nChild,accChild in (GetAccChildren(accObj), n:=0)
028: currPath:= accPath ++n ".", ParseAccData(accChild, currPath)
029: }
030: }
Continue running the script?
---------------------------
Yes No
---------------------------
---------------------------
GetAccData.ahk
---------------------------
Error: 0x80004003 - Invalid pointer
Source: (null)
Description: (null)
HelpFile: (null)
HelpContext: 0
Specifically: accChildCount
Line#
044: Return,ComObj(9, ComObjQuery(objAcc, "{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1)
045: }
047: {
048: if ComObjType(objAcc,"Name") != "IAccessible"
049: ErrorLevel := "Invalid IAccessible Object"
050: Else
050: {
---> 051: cChildren:= objAcc.accChildCount, Children:= []
052: if DllCall("oleacc\AccessibleChildren", "Ptr", ComObjValue(objAcc), "Int", 0, "Int", cChildren, "Ptr", VarSetCapacity(varChildren, cChildren * (8 + 2 * A_PtrSize), 0) * 0 + &varChildren, "Int*", cChildren) = 0
052: {
054: Loop,cChildren
054: {
055: i:= (A_Index - 1) * (A_PtrSize * 2 + 8) + 8, child:= NumGet(varChildren, i)
056: Children.Insert(NumGet(varChildren, i - 8) = 9? GetAccQuery(child): child)
057: NumGet(varChildren, i - 8) != 9? "": ObjRelease(child)
Continue running the script?
---------------------------
Yes No
---------------------------
Re: Get Title and Url of the active browser tab
Thanks for the feedback!
I was on FF 84.0.1 (32-bit) and now I installed FF 84.0.2 (64-bit) and have no such issues. However I'm on Win10 Home Version 1803 OS Build 17134.1. [Edit 1]: And AutoHotkey v1.1.31.01.
For now I updated the code with two additional try's, but am not sure how it will respond on error.
P.s.: Does Acc Viewer.ahk throw error when working on FF? [Edit 2]: Does atnbueno's code throw error or just yield wrong tab?
[Edit3]: Error: 0x80004003 - Invalid pointer might indicated problems with driver or antivirus software. For the former don't know how to fix it, for the latter you can try to disable it.
Re: Get Title and Url of the active browser tab
Updated the function to add some turbo speed for subsequent queries in a given browser instance (except for IE and Vivaldi).
Re: Get Title and Url of the active browser tab
New update. Simplified the code and performing the Obj history reset.
-
- Posts: 84
- Joined: 16 May 2020, 12:27
- Location: Italy
Re: Get Title and Url of the active browser tab
Am i ? Or the link doesn't work??
Courses on AutoHotkey
Re: Get Title and Url of the active browser tab
GetAccData Version 4.35 works fine for me ( chrome ) ... but yes at the moment .... The selected attachment does not exist anymore.
EDIT : few minutes later > LINK works ... thank you @rommmcek
EDIT : few minutes later > LINK works ... thank you @rommmcek
Last edited by garry on 14 Jan 2021, 16:12, edited 1 time in total.
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: Get Title and Url of the active browser tab
works great, i'd change google.exe to chrome.exe
Re: Get Title and Url of the active browser tab
If you mean the parameter of the GetAccData(), your right! Note that normally there's no need to specify the parameter, as default will work on active window (I'm sure you know it and take this as a side note for less advanced users).
-
- Posts: 84
- Joined: 16 May 2020, 12:27
- Location: Italy
Re: Get Title and Url of the active browser tab
In my case i have this result...
i have
Windows 10 home 1909 32bit
Chrome 87.0.4280.141
Autohotkey 1.1.33.01
i have
Windows 10 home 1909 32bit
Chrome 87.0.4280.141
Autohotkey 1.1.33.01
Courses on AutoHotkey
Re: Get Title and Url of the active browser tab
Try to close Find dialog (launched via ^f) if it is opened and press ^F8.
-
- Posts: 84
- Joined: 16 May 2020, 12:27
- Location: Italy
Re: Get Title and Url of the active browser tab
Nothing...the address of the page is always a number...
Courses on AutoHotkey
Re: Get Title and Url of the active browser tab
@rommmcek, @MancioDellaVega, this works fine for me on Win7 SP 1, 64-bit, AHK 1.33.02, but on Win10 Pro, 10.0.19041, I get the same results as @MancioDellaVega.
Regards,
burque505
Regards,
burque505
Re: Get Title and Url of the active browser tab
GetAccData works fine for me , Windows-10 64 bit 10.0.19042 , Chrome 64-bit
I used longtime this ahk basic script , copy also marked text ( get URL / Title / Text )
I used longtime this ahk basic script , copy also marked text ( get URL / Title / Text )
Code: Select all
;- start this script, copy text in browser chrome, use alt+F12
;- see result in file %a_desktop%\URL_TITLE_TEXT.txt = URL / DATE / TITLE / marked TEXT
;- copie el texto marcado en el navegador Chrome
;-------------------------------------------------------------------------------------------
/*
;-- result example :
https://www.pagina12.com.ar/317842-india-lanza-el-mayor-operativo-de-vacunacion-en-el-mundo
Copied = domingo enero 2021-01-17 10:26 UTC
India lanza el mayor operativo de vacunación en el ... | Página12
India inició la campaña de vacunación más grande del mundo contra la covid-19.
Con un población de 1.300 millones de habitantes, el país estima que para julio podrán vacunar a 300 millones de personas.
---------------------
*/
/*
see also: Get Title and Url of the active browser tab from user rommmcek
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=85383
*/
;---------------------------------------------------------------------------------------------
#warn
#NoEnv
setworkingdir,%a_scriptdir%
FormatTime,Argentina ,%a_nowutc% L0x2C0A, dddd MMMM yyyy-MM-dd HH:mm ;
timestamp=-------- Copied = %Argentina% UTC ---------------
;-https://www.autohotkey.com/docs/misc/Languages.htm languageCode_2C0A := "Spanish_Argentina"
f1=%a_desktop%\URL_TITLE_TEXT.txt
y:=" - Google Chrome" ;- delimiter for strsplit
u:=" - YouTube - Google Chrome"
*~$!F12::
#If WinActive("ahk_exe chrome.exe") ;- example for chrome browser
clipboard=
;-- copy marked text -----------
text=
sendinput, ^c
clipwait,2,1
sleep,200
if errorlevel=0
{
Text:=clipboard
sleep,200
text1 := RegExReplace(text, "([.!?¿] )", "$1`r`n") ;- new lines after .!?¿
clipboard:=""
}
;-- copy URL ------------
url:=""
send,^l
sleep,200
send,^c
clipwait,2,1
if errorlevel=0
{
url:=clipboard
send,^{end}
}
sleep,200
clipboard=
;--- copy title ---------
title=
a=
WinGetActiveTitle, title
if title contains Youtube
a:=StrSplit(title,u)
else
a:=StrSplit(title,y)
title:=a[1]
;--- remove empty lines----
Loop
{
StringReplace,text1,text1, `r`n`r`n, `r`n, UseErrorLevel
if ErrorLevel = 0
break
}
;--------------------------
if text<>
fileappend,%url%`r`n%timestamp%`r`n%title%`r`n%text1%`r`n---------------------`r`n,%f1%,UTF-8
else
fileappend,%url%`r`n%timestamp%`r`n%title%`r`n------------------`r`n,%f1%,UTF-8
;send,^r ;- reload page / remove mark from url
Splashimage,,b w700 h350 x100 Y400 CWsilver m9 b fs10 zh0,%url%`n%title%`n%text1%
sleep,1800
Splashimage, off
;----------------------
url :=""
title :=""
text :=""
text1 :=""
;clipboard:=""
#if
return
;========================================
Re: Get Title and Url of the active browser tab
Thanks for the feedback!
You could try to restart Chrome or use parameter e.g. GetAccData("chorme.exe")...
with try InStr(accObj.Value(0), ".")
or try InStr(accObj.Value(0), "/") (not sure if any address contains /)
or try InStr(accObj.Value(0), ".") && InStr(accObj.Value(0), "/")
If still does not work you can try to replace Value(0) with Name(0) in above three lines.
P.s.: If all this does not help I could post my AccSpy based on this code if anybody is willing to play with it. It is very user unfriendly, but for me the only one which retrieves e.g. AccPath(s) for any browser in fact for any window correctly.
The number indicates how many miliseconds took it to display the result, Url (address) is obviously blank.MancioDellaVega wrote:...the address of the page is always a number...
You could try to restart Chrome or use parameter e.g. GetAccData("chorme.exe")...
You could try to replace try if accObj.accRole(0) = 42 && accObj.accName(0) && accObj.accValue(0)burque505 wrote:...on Win10 Pro, 10.0.19041, I get the same results...
with try InStr(accObj.Value(0), ".")
or try InStr(accObj.Value(0), "/") (not sure if any address contains /)
or try InStr(accObj.Value(0), ".") && InStr(accObj.Value(0), "/")
If still does not work you can try to replace Value(0) with Name(0) in above three lines.
P.s.: If all this does not help I could post my AccSpy based on this code if anybody is willing to play with it. It is very user unfriendly, but for me the only one which retrieves e.g. AccPath(s) for any browser in fact for any window correctly.
Re: Get Title and Url of the active browser tab
@rommmcek, my Win10 Pro just updated. I no longer experience the errors I and @MancioDellaVega had. There's an interesting side-effect - see below. Maybe this could be expanded to report accurately for non-browser apps?
Regards,
burque505
Regards,
burque505
Re: Get Title and Url of the active browser tab
Thanks again for the feedback!
Based on that, if anybody has issues with GetAccData() it is recommended to update OS as well!
As I mentioned in postscriptum in my previous post, this kind of code works on any window. So WinTitle should be always displayed (if there is one) and address is obviously unpredictable on non browser windows... If you want to filter other windows then use parameter e.g.: GetAccData("chrome.exe")
Based on that, if anybody has issues with GetAccData() it is recommended to update OS as well!
As I mentioned in postscriptum in my previous post, this kind of code works on any window. So WinTitle should be always displayed (if there is one) and address is obviously unpredictable on non browser windows... If you want to filter other windows then use parameter e.g.: GetAccData("chrome.exe")
Re: Get Title and Url of the active browser tab
@rommmcek, thanks again to you! I forgot to ask for AccSpy.
Regards,
burque505
I'd be very happy to see it.@rommmcek said:
P.s.: If all this does not help I could post my AccSpy based on this code if anybody is willing to play with it. It is very user unfriendly, but for me the only one which retrieves e.g. AccPath(s) for any browser in fact for any window correctly.
Regards,
burque505
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 192 guests