JackyChan Posted January 12, 2009 Posted January 12, 2009 #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 ?
PsaltyDS Posted January 12, 2009 Posted January 12, 2009 #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
JackyChan Posted January 13, 2009 Author Posted January 13, 2009 (edited) Can you give me a example ? Edited January 13, 2009 by JackyChan
PsaltyDS Posted January 13, 2009 Posted January 13, 2009 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
JackyChan Posted January 14, 2009 Author Posted January 14, 2009 (edited) 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 January 14, 2009 by JackyChan
PsaltyDS Posted January 14, 2009 Posted January 14, 2009 oh. Sorry.I want to run script, then IE will run and i want to work for this caseMean: 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 ? PleaseWhat'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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now