Jump to content
Sign in to follow this  
madasraka

How to get Firefox current page address ?

Recommended Posts

madasraka

$HowMuchToTrim = "15" ;Read a number of letters of window
$WindowToFind = "Mozilla FireFox" ;Search for window matching this name after it was trimmed
$SearchForWindow = WinList()
For $i = 1 to $SearchForWindow[0][0]
If $SearchForWindow[$i][0] <> "" Then
      $TrimWindowName = Stringright ($SearchForWindow[$i][0],$HowMuchToTrim)
    If $TrimWindowName = $WindowToFind Then
        MsgBox(0, "",$TrimWindowName)
        $WindowHandle = WinGetHandle ($SearchForWindow[$i][0])
        MsgBox(0,'',$WindowHandle)
        $ReadCurrentAddress = WinGetText ($SearchForWindow[$i][0])
        MsgBox(0,'',$ReadCurrentAddress)
    EndIf
  EndIf
Next

this gets firefox window

its handle

and attempts to read text which is not there even by using AU3Info tool.

Can anyone help me to findout how to read curent firefox page address ? Not the whole thing, only the http://something.com (it should stop searching at / which comes right after com as example .com/)

I might figure out how to filter out the result for the page to shorter so i'd get only address instead of whole link, but i cant find how to get it in the first place.

REASON ?

Adding (Add/remove $var address to hosts) to block/unblock.

Want to block bad sites quickly and eazy.

Thanks in advance, i hope one of you guys will help (am sure you will just dont know which one LOL)

Edited by madasraka

Share this post


Link to post
Share on other sites
GEOSoft

$sStr = "http://www.Something.com/folder/newpage.htm"
$sDomain = StringRegExpReplace($sStr, "^(.+://.+?)/.*?$", "$1")


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
GEOSoft

I should add that if you don't know the URL string and you want to get it from the open window, use something like this simple method. There are other more conplex solutions though

Send("^l");; select the address bar
Send("^c");; copy it to the clipboard
$sStr = ClipGet()

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
madasraka

no you guys :mellow: its not the matter of changing the address link to just the address at this point but still thanks for those examples. At this point i cant even get the address in the first place.

I cant just copy and paste it, autoit needs to get the address without having user to interact with it.

Is there a way for autoit to read address which displayed in firefox address bar or whatever address it is connected to ?

Edited by madasraka

Share this post


Link to post
Share on other sites
GEOSoft

If FF is visible this will do it.

AutoItSetOption ("WinTitleMatchMode", 2 )

WinActivate  ("Mozilla Firefox")
Send("^l");; selects the address bar contents
Send("^c");; copies it to the clipboard
$sDomain = StringRegExpReplace(ClipGet(), "^(.+://.+?)/.*?$", "$1")
MsgBox(0, "Result", $sDomain)

There is no need for the user to interact with the keyboard.

If you want something else then search Example scripts for the FF.au3 UDF. I only leave FF installed for, at most, a few days at a time so I've had no use for that UDF and I don't know what all is in it, but you may find something.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.