mIRC Home    About    Download    Register    News    Help

Print Thread
#266001 03/09/19 10:59 AM
Joined: Oct 2017
Posts: 47
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Oct 2017
Posts: 47
There are some problems with $url in 7.57

Tested under Windows 10.18362.329

1): $url is broken under Chrome (latest version - 76.0.3809.132).
2): $url not working (tested in all browsers) if the active URL is: http://localhost or http://localhost:PORT or file:///c:/path/filename

- GG

Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
Thanks for your bug report. It looks like newer versions of Chrome have changed some aspect of their accessibility interface.

I have made a change to $url that fixes this, however...

When $url was added long ago, browsers supported DDE to retrieve the active URL. Unfortunately, DDE has been phased out, and browsers no longer provide a simple method for other applications to retrieve the active URL. I implemented a method some versions ago that searches a browser's interface, apparently the only way to do it now, and tries to find something that looks like a URL. The method needs to know the class name for every browser that it has to work with. It is a very brittle implementation and I expect $url will break again and again, every time a browser changes its implementation.

Apart from that, you will find that $url only retrieves fully formed http/ftp addresses. It did support other prefixes and non-full addresses at one point, however this often resulted in invalid results, so support for these was removed.

Joined: Oct 2017
Posts: 47
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Oct 2017
Posts: 47
Ok, I will wait for the next beta to test it out..

Joined: Oct 2017
Posts: 47
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Oct 2017
Posts: 47
I've test out the 1701 beta but seems that is still broken, I still get $null when using $url on chrome (latest version).

Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
Thanks for the feedback. It is working correctly for me in Chrome. Have you set Chrome as your default windows browser through the Windows 10 Options default apps section?

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Under win7-32 i was seeing a problem. The first time I used $url the beta froze for a few seconds until $url returned $null when the default browser was I.E. But the 2nd and later times it would return the normal value. When I changed browser to chrome, there was also the short freeze the 1st time using $url. But there were no more freezes on later usages of $url, even after switching the default browser back and forth, and no problems other than the very 1st usage of $url with each browser.

Last edited by maroon; 12/09/19 08:27 AM.
Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
The method that applications need to use to find the active URL involves searching the accessibility interface (via UI automatiion) for a URL. This is a slow process and will be much slower, and may freeze, on the first attempt.

The process could be speeded up but the method would literally have to be hard-coded for every browser... its current class name, its accessibility interface, the sections that mIRC needs to read to find the active URL. These will be different for every browser... and will break every time a browser releases a new version that changes any of these. Basically, it will be a never-ending process of updating $url because it keeps breaking.

As for it not working on the first attempt with IE, I have not been able to reproduce this here and cannot think of a reason why that would happen. The same search method is used every time. That said, the UISpy and Inspect applications provided by Microsoft for browsing the current accessibility interfaces of applications, both running in administrator mode, seem unreliable when retrieving the accessibility interface. Both needed to be restarted to refresh their contents correctly, despite having a refresh button. That does not bode well for other applications trying to do the same thing.

Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
Quote
The first time I used $url the beta froze for a few seconds until $url returned $null when the default browser was I.E.

Right. Apparently, this is because when I first added support for this, it took so long to complete on the initial run that I decided to add a timeout in case there was an issue. If it took longer than three seconds, $url would give up the search. I am going to remove the timeout. This means that from the next beta, if you use $url, mIRC could freeze for an undetermined amount of time.

Then again. I just found out that Microsoft Edge runs continuously in the background due to the Windows 10 background apps feature. This means that if you have Edge as your default browser but are currently using another browser, $url will find Edge running and will try to retrieve the active URL from it, which will be empty. The only solution so far is that if the returned URL is empty, mIRC will continue searching for other matching Window class names, eg. MozillaWindowClass for Firefox, etc., and if they are available, it will search them as well. Alternatively, mIRC could always leave Edge till last when searching and always give priority to other browser class names...

This is truly one giant hack.

Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
Khaled

I would really advise against removing the timeout completely - because then the only route out of it is either Ctrl-Break (which might or might not work) or killing mIRC process completely and restarting it. Instead I would suggest:

1. Make Ctrl-Break work to interrupt it.

2. If you can do one, set a timeout of (say) 60s. If not, make a timeout of (say) 30s. This would be the amount of time a user might realistically wait before deciding to kill the mIRC process and relaunch it - an action that should IMO be avoided if at all possible.

3. Alternatively, if you can, if you don't get a response within (say) 10s, you could display some sort of pop-up which explains what is happening and allows the user to cancel.

P

Joined: Jul 2006
Posts: 4,144
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
It might be a good idea to accept that $url was based on not so reliable method, to keep it working more or less, and to extend it to support a parameter, a classname or the name of the executable, if khaled can work from that, without looking at millions of classes, that would be reliable and would allow support for any browser, which the current method doesn't provide.

Last edited by Wims; 12/09/19 06:54 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Oct 2017
Posts: 47
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Oct 2017
Posts: 47
What about to make the $url work only with MS Edge and IE as these two comes as default with Windows?

And if it is possible using COM or DLL methods to create an custom identifier to return of whatever browser you want the URL then it would more safe for someone to use $url in their codes
because now even a coder creates a code using $url that $url suppose to work with every market browser (at least the most famous) then in future if $url will break (for any browser for any reason) it will make problems and in the code, and you will have to find a way to fix the broken code in order to make $url available again for that broken browser.

So my simple suggestion is to make $url work with what Windows comes from default and let the user to code an extra DLL or COM (if it is possible) to grab the url of what ever browser he likes by using an custom identifier, so the coder can specify that his code including $url can only works with MS Edge or IE .

- GG

Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
Quote
It might be a good idea to accept that $url was based on not so reliable method, to keep it working more or less, and to extend it to support a parameter, a classname or the name of the executable, if khaled can work from that, without looking at millions of classes, that would be reliable and would allow support for any browser, which the current method doesn't provide.

Unfortunately, the class/executable name is the least of our worries.

For example, the issue reported in this thread is due to Chrome changing its accessibility format, not the class/executable name.

Every browser uses a different accessibility format.

The only possibly reliable method would be for $url to search through every accessibility item for a URL-like match, instead of trying to perform some intelligent filtering like it does now. But this would be even slower than it is now. And it would get slower the more websites you have open.

I have also just found out that when Microsoft Edge is minimized, it no longer provides the URL via an accessibility search. Other browsers continue to provide the URL when minimized. So $url will always fail if Edge is being used and is minimized.

On a positive note, I found an API that allows mIRC to detect if Microsoft Edge is running as a background application, so that $url can skip looking through it.


Link Copied to Clipboard