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.