Jump to content

Read URL from most 5 used browsers


Recommended Posts

Hi everyone,

I'm trying to find out a way to read a url from Internet Explorer, Mozilla Firefox, Google Chrome, Safari and Opera. I've updated all those browsers to the latest version. Yashied's control viewer at helped me finding what I needed to know about the GUI's. Thanks a lot, Yashied!

Internet Explorer was not so difficult. A comment from herewasplato at brought me on this idea:

MsgBox(0, "", ControlGetText("[CLASS:IEFrame]", "", "Edit1") )

Google Chrome is a little more difficult. I havn't found a way to refer to it using [CLASS:], so it looks like I'll have to use the entire name of the window. The problem is, this depends on the currently opened site. The example below works when you're visiting http://www.autoitscript.com/site/.

MsgBox(0, "", ControlGetText("AutoItScript - AutoItScript Website - Google Chrome", "", "Chrome_OmniboxView1") )

Safari is even more difficult. Again, I couldn't solve this using [CLASS:] and depending on the visited site, the entire title of the browser window changes. When visiting www.google.com it just says 'Google', instead of 'Google - Safari' or something like that. This makes it very difficult for my program to even recognize it as a safari browser window. Also, when trying to read the adress bar ([CLASS:SafariEdit; INSTANCE:1]), it always says it's empty. Even the control viewer gives this result. Suggestions?

What remains are Firefox and Opera. They both seem to be using XULand the best solution I've seen came from lainline at

#include <ClipBoard.au3>

AutoItSetOption ("WinTitleMatchMode", 2 )

WinActivate ("Mozilla Firefox")

Send("^l")

Send("^c") $address=_ClipBoard_GetData($CF_TEXT)

MsgBox( 0, "asdf", $address )

This last method also works for all other browsers, so in theory, my problem is solved. If anyone thinks of a better way to get a url from any of these browsers though, I'd really appreciate that. Also I hope my post is a little clear.

Link to comment
Share on other sites

Hello helmsman,

First, When working with Window Titles, you can find windows by partial match with Opt('WinTitleMatchMode', 2)

Opt('WinTitleMatchMode', 2)
MsgBox( '', '', ControlGetText('Google Chrome', '', '[CLASS:Chrome_OmniboxView; INSTANCE:1]' ) )

This example worked fine for me.

As for locating classes of window objects, AutoIt included with the standard download a handy little tool called 'AutoIt v3 Window Info' and can be found in the main AutoIt installation directory, normally in Program Files and the application is titled 'Au3Info.exe'. If you use the 'Finder Tool' and drag it over a control, it will give you all the information needed to automated those controls. Some Applications do not use the standard Microsoft Window controls, which make it difficult for this tool to read controls. Most if not all Web browsers use the standard Microsoft Window controls.

Good Luck and Happy Coding!

Realm

Edit: Sorry, didn't see you were using the other form of Opt(), however the rest of my advice may be interesting to you.

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

Hello Realm,

Thank you for your tips and advice. I guess I've been staring too much at my problem to think of using WinTitleMatchMode 2 in combination with Google Chrome. :-p I'll see what Au3Info.exe can do for me and if I find any new solutions, I'll post them of course. ;-)

Thank you again,

Helmsman

Link to comment
Share on other sites

helmsman,

My Pleasure! Aslo, Opt('WinTitleMatchMode', 2) will apply to any portion of your script that follows after it. If you need an Exact search again later, you can change it again with Opt('WinTitleMatchMode', 3) just before it is needed. Opt() AutoItSetOption() are the same exact function, and Ultimately they don't set the paramter for your entire script, only the portion that follows after you call it.

Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

Thanks for the hint :). Your technique of Chrome works for me too. That makes 2/5 solved. ;) As I expected, Au3Info can't help me with firefox or Opera either, so I'm going to search the web for some clues of how to handle XUL. Also, on Safari, Au3Info gives the same problem as Control Viewer. When I hover over the adress bar, I get a lot of information:

Class: SafariEdit

Instance: 1

ID: 2127249888

Style: 0x56000000

ExStyle: 0x00000000

Position: 118, 12

Size: 704, 17

Handle: 0x00020DC8

Text:

But the text remains blanco, although there is a URL in the adress bar. I guess this is going to be web browsing work too. :D

Helmsman

Link to comment
Share on other sites

I'm trying to work it out using the FF UDF right now

but I'm getting a lot of errors. However, if I find a way to read the FF adress bar, I'll post it, because I might not be the last person wanting to do this. ;)

Any help suggestions are of course still welcome. It's not really working out yet.

Helmsman

Link to comment
Share on other sites

  • 2 months later...

I'm using Safari browser,

And i could not able to enter the text in the search bar text box.

Pl help me

Title: Safari: Browser Window and Menu Shortcuts

Class: {1C03B488-D53B-4a81-97F8-754559640193}

Position: -8, -8

Size: 1616, 876

Style: 0x17CF0000

ExStyle: 0x00000100

Handle: 0x000A03BA

>>>> Control <<<<

Class: SafariEdit

Instance: 1

ClassnameNN: SafariEdit1

Name:

Advanced (Class): [CLASS:SafariEdit; INSTANCE:1]

ID: 2146053408

Text:

Position: 118, 32

Size: 917, 18

ControlClick Coords: 278, 9

Style: 0x56000000

ExStyle: 0x00000000

Handle: 0x0022045E

>>>> Mouse <<<<

Position: 396, 63

Cursor ID: 0

Color: 0xFFFFFF

>>>> StatusBar <<<<

Link to comment
Share on other sites

I'm trying to work it out using the FF UDF right now

but I'm getting a lot of errors. However, if I find a way to read the FF adress bar, I'll post it, because I might not be the last person wanting to do this. ;)

Any help suggestions are of course still welcome. It's not really working out yet.

Helmsman

Link to comment
Share on other sites

  • 1 year later...

I'm trying to work it out using the FF UDF right now

'?do=embed' frameborder='0' data-embedContent>>

but I'm getting a lot of errors. However, if I find a way to read the FF adress bar, I'll post it, because I might not be the last person wanting to do this. ;)

Any help suggestions are of course still welcome. It's not really working out yet.

Helmsman

.

how i wish he would have posted the solution :)

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...