Page 3 of 10
Re: Get the URL of the current (active) browser tab
Posted: 14 Apr 2016, 15:16
by atnbueno
Hello again.
Kudos, could you please check this version of the script with your Edge browser?
https://dl.dropboxusercontent.com/u/741 ... _kudos.ahk
For now it's just an ugly workaround but I'd like to know if I'm in the right path to nail the problem with ApplicationFrameWindow.
Regards,
Antonio
[EDIT 2016-04-15]I think I found the problem. I've updated the script above with the tentative solution (no ugly workaround needed!
).
[/EDIT]
Re: Get the URL of the current (active) browser tab
Posted: 15 Apr 2016, 02:15
by haichen
Hi atnbueno,
it works with firefox nightly multiprocess
but Edge produces an error for loading a type bib/dll
Code: Select all
---------------------------
GetActiveBrowserURL_kudos.ahk
---------------------------
Error: 0x80029C4A - Fehler beim Laden der Typbibliothek/DLL.
Source: (null)
Description: (null)
HelpFile: (null)
HelpContext: 0
Specifically: accChildCount
Line#
119: Return,ComObj(9, ComObjQuery(Acc,"{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1)
120: }
121: {
122: if ComObjType(Acc,"Name") != "IAccessible"
123: ErrorLevel := "Invalid IAccessible Object"
124: Else
124: {
---> 125: Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
126: if DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0
126: {
127: Loop,%cChildren%
128: i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i), Children.Insert(NumGet(varChildren,i-8)=9?Acc_Query(child):child), NumGet(varChildren,i-8)=9?ObjRelease(child):
129: Return,Children.MaxIndex()?Children:
130: }
130: Else
Continue running the script?
---------------------------
Ja Nein
---------------------------
Re: Get the URL of the current (active) browser tab
Posted: 15 Apr 2016, 14:36
by atnbueno
I'm glad it works with
Firefox Nightly,
haichen
About the error, I don't know what to tell you
The only DDL used for non-legacy browsers (like both
Firefox Nightly and
MS Edge) is
oleacc.dll
Regards,
Antonio
P.S. Test script updated above
Re: Get the URL of the current (active) browser tab
Posted: 16 Apr 2016, 12:41
by haichen
Now I had time to test it on my netbook and it worked with edge. Gratulation!! and thank you. So my desktop pc may have a problem..
Re: Get the URL of the current (active) browser tab
Posted: 11 May 2016, 08:59
by goosey
Is there any way to get this to work with Vivaldi browser (based on Chrome)? I've tried a few work arounds using control l+ control c but it's very unreliable.
Re: Get the URL of the current (active) browser tab
Posted: 11 May 2016, 15:55
by atnbueno
goosey, unfortunately no
Vivaldi does not support neither
DDE nor
MSAA (the two methods my script uses to get information from the browsers).
As soon as version 1.1 came out I re-tried, again without success
Re: Get the URL of the current (active) browser tab
Posted: 12 May 2016, 09:09
by goosey
Ok, thank you for answering. Time to refine copy and paste timing then, setting show full url helped by the way, for anyone else reading.
Re: Get the URL of the current (active) browser tab
Posted: 15 May 2016, 01:52
by technotron
I got this script working just fine with both Firefox and Chrome. However, the url cannot be determined with the Pale Moon browser. Are you willing to add support for it? It was originally derived from older versions of Firefox's code and branched from it.
site:
https://www.palemoon.org/
>>>>>>>>>>( Window Title & Class )<<<<<<<<<<<
Pale Moon - Congratulations - Pale Moon
ahk_class MozillaWindowClass
Re: Get the URL of the current (active) browser tab
Posted: 15 May 2016, 07:10
by atnbueno
technotron, if
ahk_class is "MozillaWindowClass", the
tweak I mentioned a couple of months ago should work with Pale Moon (both x86 and x64 versions). If there's any problem, I'll gladly look into it
I've updated the
original code with this change, as well as with the fix for occasional Edge problems
Regards,
Antonio
P.S.
I've asked in the Vivaldi forums about automation/accessibility support and they say they're working on it
Re: Get the URL of the current (active) browser tab
Posted: 15 May 2016, 10:57
by haichen
Found this Accessibility Viewer
https://www.paciellogroup.com/resources/aviewer/
May be this could be interesting for you (or others).
Re: Get the URL of the current (active) browser tab
Posted: 15 May 2016, 13:10
by technotron
I tried out the new script on both Pale Moon 32 bit and 64 bit. Unfortunately it still cannot determine the url. It still works on Firefox and Chrome though.
By the way, on line 66 are the quotes supposed to be unclosed?
Code: Select all
StringSplit, sWindowInfo, csvWindowInfo, `"
Re: Get the URL of the current (active) browser tab
Posted: 15 May 2016, 17:43
by atnbueno
Hello again.
technotron, you're right. I've tried both x86 and x64 versions of Pale Moon and I can't reach the address bar (my script needs a "path" from the window to the address bar than can be detected with ACC). It's the same problem I have with the Vivaldi browser: The address bar is there, but I can't find it with the accessibility API
Specifically, if I can't "select" the address bar with
jethrow's
AccViewer.ahk, I can't read it
I'm mentioning this because I'm stumped with this case. Right now I have no clue on how to solve it. Ideas, anyone?
And
haichen, thanks for the link. I use another viewer but the one you link provides additional information
Regards,
Antonio
P.S. I forgot: Yes, that single double quote is correct (it's the character to use as delimiter for the string splitting)
Re: Get the URL of the current (active) browser tab
Posted: 16 May 2016, 11:11
by qwerty12
Hi,
atnbueno wrote:I've tried both x86 and x64 versions of Pale Moon and I can't reach the address bar (my script needs a "path" from the window to the address bar than can be detected with ACC).
Pale Moon say they disabled accessibility features explicitly:
https://www.palemoon.org/technical.shtml#features
It's the same problem I have with the Vivaldi browser: The address bar is there, but I can't find it with the accessibility API
There's a kind-of workaround for Vivaldi (actually works in Chrome too to play with the rendered web page): turn on global accessibility mode in
chrome://accessibility. I say workaround because:
- While the address bar does get exposed (95% sure of this - sometimes I found it with Microsoft's Inspect [Object]), so do the rest of the elements on the page...
- Leaving the mode on does slow things down a bit when browsing...
- And, of course, users must enable the mode first
- The global accessibility mode does not seem to persist when the browser is restarted
Best regards
Re: Get the URL of the current (active) browser tab
Posted: 16 May 2016, 12:34
by atnbueno
Thanks,
qwerty12. Really useful information.
The Pale Moon link is clear: They don't care for automation/accessibility, so I guess I won't care about Pale Moon
I did not gave up inmediately. I also tried using DDE (the older inter-process messaging technology I use with legacy browsers) but it didn't work either
The information about Vivaldi is a bit more hopeful. The address bar
can be reached in this mode, although it requires some very specific steps to get the full URL (unless "Show full URL" is also enabled by the user in the address bar options). The lack of persistence is annoying, but at least the functionality is there
Let's hope they decide to enable accessibility at least for the UI.
Regards,
Antonio
Re: Get the URL of the current (active) browser tab
Posted: 16 May 2016, 17:35
by Kudos
Hi Antonio,
I'm really sorry for not replying for so long. I was unaware of all the replies here.
I have just tried the latest code and I still consistently have the same issue in MS Edge 'The URL couldn't be determined'. Do you have any suggestions of what I can do to help troubleshoot this?
I would gladly try any ugly workaround if you can share that again.
Thanks!!
Kudos
Re: Get the URL of the current (active) browser tab
Posted: 18 May 2016, 15:16
by atnbueno
Hello
Kudos,
Don't worry. We all have our downtimes
If the current code still fails, I still have no idea of what's happening to you. I've been using Edge with the published code for days without a single problem.
But hey, let's keep trying. I've gone back to the "ugly workaround" in this version:
https://dl.dropboxusercontent.com/u/741 ... _kudos.ahk
Please try it and let's see if anything changes on your side.
Regards,
Antonio
P.S. I've also found a not-very-ugly workaround for Vivaldi that seems to work 100%
Re: Get the URL of the current (active) browser tab
Posted: 18 May 2016, 15:51
by qwerty12
atnbueno wrote: I've also found a not-very-ugly workaround for Vivaldi that seems to work 100%
Nice work!
Re: Get the URL of the current (active) browser tab
Posted: 18 May 2016, 16:48
by Kudos
Hi Antonio!
It turns out I've been really stupid!
My dev machine has not installed updates for ages so I was running an old version of Edge - 20.10240. Tried your latest code and the workaround on another PC of mine with (more recent) Edge 25 and both work perfectly.
So I think my issue was just that I need to install updates!
Thanks for all your help!
Kudos
Re: Get the URL of the current (active) browser tab
Posted: 19 May 2016, 06:11
by technotron
That's really too bad. I tried to approach this different way. I used a greasemonkey script since it has a function that can set the clipboard and can interact the browser directly. Here's the code snippet if anyone is interested. It's not autohotkey though:
Code: Select all
==UserScript==
// @name custom grim's copy_page_url
// @namespace namesp
// @description copies page url with ctrl + shift + c
// @include *
// @version 1
// @grant GM_setClipboard
// ==/UserScript==
// http://stackoverflow.com/questions/13075645/how-to-copy-data-to-the-clipboard-with-greasemonkey
var pageUrl = window.location.href
var textToCopy = pageUrl;
// start copy text to clipboard
(function(){
document.addEventListener('keydown', function(e) {
// pressed ctrl+shift+c
if (e.keyCode == 67 && e.shiftKey && e.ctrlKey && !e.altKey && !e.metaKey) {
GM_setClipboard(textToCopy);
}
}, false);
})();
Re: Get the URL of the current (active) browser tab
Posted: 19 May 2016, 15:50
by atnbueno
Kudos, ouch
technotron, I'm a big fan of GreaseMonkey/TamperMonkey myself
A quite common trick to expose the URL of each tab is to add it to the page title when it loads, so AutoHotkey can easily get it. The GM script for this couldn't be simpler and you wouldn't need to use the clipboard or listen to the keyboard inside every tab
I've just updated the code and added the Vivaldi workaround in the
original post, in case anyone is interested.
Regards,
Antonio