Jump to content

Get cuurent URL using IE.au3


plat
 Share

Recommended Posts

Hi;

I am having trouble with IE.au3 syntax; The following code will navigate to an url already in the clipboard but what I am trying to achieve is to capture the current URL to a variable- say by right clicking a systray context menu from the application I am writing.

The end aim is to be able to download the current page using InetGet for offline string parsing without having to hightlight the text in the URL bar first as the example below would require.

Any thoughts greatly appreciated...

#include <IE.au3>

$sURL = ClipGet()

$oIE = _IECreate ($sURL)

$addr = _IEPropertyGet ($oIE, "LocationURL")

Msgbox(0, "", $addr)

Link to comment
Share on other sites

Your syntax looks fine. I ran your code and ended up with the current URL in $addr

What happens for you? Do I misunderstand your question?

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Your syntax looks fine. I ran your code and ended up with the current URL in $addr

What happens for you? Do I misunderstand your question?

Dale

Hi Dale; The bit I am having trouble with is how to get $addr assigned on the fly; Surf the net and at I time I choose hit a key and the script grabs the current url for me (i.e. no need to manually select contents of address bar & ctrl+c to populate the clipboard)

Link to comment
Share on other sites

how to get $addr assigned on the fly; Surf the net and at I time I choose hit a key and the script grabs the current url for me

I'm sorry, I need to to be more explicit about what you are trying to do. This is way too ambiguous.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

#include <IE.au3>
Opt("GUIOnEventMode", 1)
global $title = "IE Monitor"

; the following sets CTRL-F12 as your on the fly url grabbing hotkey, 
; but change this to what you want
if not HotKeySet ( "^{f12}" , "graburl" ) then 
    msgbox(0,$title,"Error, could not set graburl hotkey")
    Exit
EndIf
if not HotKeySet ( "{esc}" , "abort" ) then 
    msgbox(0,$title,"Error, could not set abort hotkey")
    Exit
EndIf


$sURL = ClipGet()
if stringinstr($sURL,"http://") Then
    global $oIE = _IECreate ($sURL)
Else
    global $oIE = _IECreate ()
EndIf

while 1
    sleep(1000)
WEnd


func graburl()
    $addr = _IEPropertyGet ($oIE, "LocationURL")
    clipput($addr)
    Msgbox(0, $title, $addr)
EndFunc

func abort()
    Msgbox(0, $title, "Esc pressed, aborting")
    Exit
EndFunc

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/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...