Get Title and Url of the active browser tab

Post your working scripts, libraries and tools for AHK v1.1 and older
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Get Title and Url of the active browser tab

09 Apr 2021, 00:01

The flag --force-renderer-accessibility or sending WM_GETOBJECT needed depending on what exact data You need with chrominium interface.
My code saves acc object. It does not matter how we get acc object.
I save acc object and can use it with any tab in vivaldi window.
Therefore You need look at Your code, if You cannot use saved acc object with vivaldi then Your code has bugs.
Also Vivaldi has some trick.
To use its accessible interface without --force-renderer-accessibility flag We can like this:

Code: Select all

f11::
if !init
{
   init := 1
   SendMessage, WM_GETOBJECT := 0x003D, 0, 1, Chrome_RenderWidgetHostHWND1, % "ahk_id " WinExist("A")		
   acc := Acc_Get("object", "4",, "A") 
   acc.accName(0)   ; needed for rebuilding acc tree
   loop
   {
      acc := Acc_Get("object", "4.1.2.1.1.1.1.1.2.1.2.3.1.1",, "A")
      if isobject(acc)
         break
      sleep 10
   }
}
msgbox % acc.accvalue(0)
return
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Get Title and Url of the active browser tab

10 Apr 2021, 10:27

For better reliability, like this

Code: Select all

f11::
if !init
{
   init := 1
   SendMessage, WM_GETOBJECT := 0x003D, 0, 1, Chrome_RenderWidgetHostHWND1, % "ahk_id " WinExist("A")		
   acc := Acc_ObjectFromWindow(WinExist("A"))
   acc.accName(0)   ; needed for rebuilding acc tree
   loop
   {
      acc := Acc_Get("object", "4.1.2.1.1.1.1.1.2.1.2.3.1.1",, "A")
      if isobject(acc)
         break
      sleep 10
   }
}
msgbox % acc.accvalue(0)
return
User avatar
rommmcek
Posts: 1475
Joined: 15 Aug 2014, 15:18

Re: Get Title and Url of the active browser tab

10 Apr 2021, 10:30

Thank you very much, your involvement is sincerely appreciated!

I definitely think I had Acc somehow partially blocked..., besides I had a retrieving a correct AccPath issue (now fixed).
Your last code rocks and was even to good for me... preventing me to explore Acc being blocked. It somehow unblocked Acc and all works as it should!

Updated the OP - new improved version

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 138 guests