Jump to content
Sign in to follow this  
JackyChan

_IEAttach before ?

Recommended Posts

JackyChan

#include<ie.au3>
$oIE = _IEAttach("google.com")
$oEvt = ObjEvent($oIE,"IEEvent_","DWebBrowserEvents2")

while 1
sleep(10)
wend

Func IEEvent_BeforeNavigate2($notsurewhatthisis,$url,$TargetFrameName,$PostData,$Headers, $Cancel)
;;;;;
consolewrite($url&@CR)
 EndFunc

That script is work. But it'll only work when i run google.com before and not work when i run google.com after the script.

How to make it work when i run google.com after the script ?

Share this post


Link to post
Share on other sites
PsaltyDS

#include<ie.au3>
$oIE = _IEAttach("google.com")
$oEvt = ObjEvent($oIE,"IEEvent_","DWebBrowserEvents2")

while 1
sleep(10)
wend

Func IEEvent_BeforeNavigate2($notsurewhatthisis,$url,$TargetFrameName,$PostData,$Headers, $Cancel)
;;;;;
consolewrite($url&@CR)
 EndFunc

That script is work. But it'll only work when i run google.com before and not work when i run google.com after the script.

How to make it work when i run google.com after the script ?

You are only capturing events from that instance of IE ($oIE). If you get a new instance, by _IECreate() or _IEAttach() for example, then you have to redo the ObjEvent() for that object.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
JackyChan

Can you give me a example ?

Edited by JackyChan

Share this post


Link to post
Share on other sites
PsaltyDS

Can you give me a example ?

Well, first your _IEAttach() is wrong. This works for a pre-existing instance of IE:
#include<ie.au3>

HotKeySet("{ESC}", "_Quit")

$oIE = _IEAttach("http://www.google.com", "URL")
$oEvt = ObjEvent($oIE, "IEEvent_", "DWebBrowserEvents2")

While 1
    Sleep(10)
WEnd

Func IEEvent_BeforeNavigate2($notsurewhatthisis, $url, $TargetFrameName, $PostData, $Headers, $Cancel)
    ConsoleWrite($url & @CR)
EndFunc  ;==>IEEvent_BeforeNavigate2

Func _Quit()
    Exit
EndFunc  ;==>_Quit

Second, it works exactly the same for browser instances you create later:

#include<ie.au3>

HotKeySet("{ESC}", "_Quit")

$oIE_1 = _IECreate("http://www.google.com", "URL")
$oEvt_1 = ObjEvent($oIE_1, "IEEvent_", "DWebBrowserEvents2")

Sleep(2000)

$oIE_2 = _IECreate("http://www.autoitscript.com", "URL")
$oEvt_2 = ObjEvent($oIE_2, "IEEvent_", "DWebBrowserEvents2")

While 1
    Sleep(10)
WEnd

Func IEEvent_BeforeNavigate2($notsurewhatthisis, $url, $TargetFrameName, $PostData, $Headers, $Cancel)
    ConsoleWrite("Navigated to:  " & $url & @CR)
EndFunc  ;==>IEEvent_BeforeNavigate2

Func _Quit()
    Exit
EndFunc  ;==>_Quit

So, what was the question?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
JackyChan

oh. Sorry.

I want to run script, then IE will run and i want to work for this case

Mean: IE(http://google.com) hasn't already exist. Script is running. And when IE(http://google.com) has already exist, it will attach IE(google) and the events will write in console.

Can you help me ? Please

Edited by JackyChan

Share this post


Link to post
Share on other sites
PsaltyDS

oh. Sorry.

I want to run script, then IE will run and i want to work for this case

Mean: IE(http://google.com) hasn't already exist. Script is running. And when IE(http://google.com) has already exist, it will attach IE(google) and the events will write in console.

Can you help me ? Please

What's wrong with the code I put in post #4? The first example works to _IEAttach() to an existing instance, and the second example creates new ones.

What are you still missing?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×