Jump to content

objEvent for Windows 10 Internet Explorer not working - (Moved)


Yodavish
 Share

Recommended Posts

I have this AutoIt script that works on Windows 7. However, when I test it on Windows 10, the objEvent will not execute the function it's supposed to call. So I have a webpage the script will check if it is active, then it will search if a popup button exist (elementId), if so, assign it to the event handler so that when that button is clicked, then handler function will move the focus back to the main GUI again.

If WinActive("Website Title - Internet Explorer") Then
   $ie = _IEAttach("Website Title")
   $objElement= _IEGetObjById ($ie, "elementId")
   local $oEvent = ObjEvent($objElement, "_MY_EVENT_HANDLER_")
EndIf

Func _MY_EVENT_HANDLER_onclick($oEvtObj)
    msgbox(0,"Alert Window", "Button Clicked!")
    setMainWindow() ; sets focus back to main GUI
EndFunc

 

I've verified, on Windows 10, that it does see the object element. But it will not trigger the event. Could it be related to some timing issues due to Windows 10 Internet Explorer over Windows 7 Internet Explorer? 

Windows 7 IE version 11.0.9600.19507

Windows 10 IE version 11.418.18362.0

AutoIt v 3.3

 

Edited by Yodavish
Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

@Nine Thanks for the reply,

I added some consoleWrites to look at each of the output variables but it didn't show me anything and it still won't run on Windows 10. When I click on the button that's related to the handler, nothing for the SCILite output. 

I'm still relatively new to AutoIt, so please let me know if I can log this better somehow. My code and the results in the SCILite console are below:

If WinActive("Website Title - Internet Explorer") Then
   $ie = _IEAttach("Website Title")
   ; Also tried passing the handle here
   $objElement= _IEGetObjById ($ie, "elementId")
   consoleWrite('ButtonElement' & $objElement & @CRLF)
   local $oEvent = ObjEvent($objElement, "_MY_EVENT_HANDLER_")
   ConsoleWrite('ObjEvent' & $oEvent & @CRLF)
EndIf

Func _MY_EVENT_HANDLER_onclick($oEvtObj)
    ConsoleWrite('_MY_EVENT_HANDLER_onclick' & $oEvtObj & @CRLF)
    setMainWindow() ; sets focus back to main GUI
EndFunc
>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\gross\Gross.au3"    
ButtonElement
ObjEvent
>Exit code: 0    Time: 47.19

 

Edited by Yodavish
Link to comment
Share on other sites

@Danp2 Thanks, I've modified the consoleWrite and added and a @error for a popup msgbox under the objEvent but didn't receive any msgbox either. My code is below:

If WinActive("Website Title - Internet Explorer") Then
   $ie = _IEAttach("Website Title")
   ; Also tried passing the handle here
   $objElement= _IEGetObjById ($ie, "elementId")
   consoleWrite('ButtonElement: ' IsObj($objElement) & @CRLF)
   local $oEvent = ObjEvent($objElement, "_MY_EVENT_HANDLER_")
   if @error <> 0 Then MsgBox(0,"ERROR DETECTED",@error)
   ConsoleWrite('ObjEvent: ' & IsObj($oEvent) & @CRLF
EndIf

Func _MY_EVENT_HANDLER_onclick($oEvtObj)
    ConsoleWrite('_MY_EVENT_HANDLER_onclick: ' & IsObj($oEvtObj) & @CRLF)
    setMainWindow() ; sets focus back to main GUI
EndFunc
ButtonElement: 1
ObjEvent: 1

 

I tested it on my Windows 7 desktop to compare:

ButtonElement: 1
ObjEvent: 1
_MY_EVENT_HANDLER_onclick: 0

I'm open to other suggestions to get this to work, if I can't use IE from Windows 10?

Edited by Yodavish
Link to comment
Share on other sites

Link to comment
Share on other sites

@Nine I've updated my code and tried to run in on Windows 7, however, it no longer works here, but I'll try it on Windows 10 and check. Below is the code:

 

$ie = _IEAttach("Website Title")
   ; Also tried passing the handle here
   $objElement= _IEGetObjById ($ie, "elementId")
   Local $oDocument = $ie.document
   consoleWrite('ButtonElement: ' IsObj($objElement) & @CRLF)
   Global $oEvent = ObjEvent($oDocument, "_MY_EVENT_HANDLER_", "HTMLDocumentEvents2")
   ;if @error <> 0 Then MsgBox(0,"ERROR DETECTED",@error)
   ;ConsoleWrite('ObjEvent: ' & IsObj($oEvent) & @CRLF

 

Link to comment
Share on other sites

@Danp2 Ah I solved it since you mentioned a possible exit immediately before the event is captured, I decided to move this portion of the code up in my while loop and it now triggers the event properly when the browser is active. Thanks everyone for your help. I'll need to put consoleWrites all on my functions to see the order of which occur to see the order of it properly.

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

×
×
  • Create New...