Jump to content
Yodavish

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

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

@Yodavish Perhaps you could post a fully working reproducer script using a publicly available website? As is, we can only guess at the issue because the code you've shared thus far would exit immediately after being run, so there's no possibility for the event to be captured.

Share this post


Link to post
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.

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

  • Similar Content

    • By somebadhat
      Restore blank Windows 10 start menu icons.
      ; RESTORE BLANK WINDOWS 10 START MENU ICONS. ; TOGGLE SETTINGS-START-"USE START FULL SCREEN" TWICE ; THIS WILL RESTORE SOME OF THE BLANK ICONS ; FOR THOSE THAT IT DOES NOT REDO "CHANGE ICON" FROM THE PROPERTIES DIALOG BOX FOR EACH MISSING ICON. ; "C:\Program Files (x86)\AutoIt3\AutoIt3_x64.exe" "F:\MYAPPS\WINDOWS\StartMenu1.au3" ; windows 10 and autoit3 ; begin restore blank icons on start menu Run(@ComSpec & " /c start ms-settings:personalization-start", "", @SW_SHOWMINIMIZED) Sleep(500) WinWaitActive("Settings") Sleep(1000) ; WinWaitActive ("[CLASS:ApplicationFrameInputSinkWindow]", "") ; ; BEGIN https://www.autoitscript.com/forum/topic/1353-check-if-a-computer-is-online/ $Computer = "8.8.8.8" AutoItSetOption ("SendKeyDelay" , "125") ;was 55, 500 If RunWait("ping.exe -n 1 " & $Computer, "", @SW_HIDE) == 0 Then WinActivate("Settings") send("{tab}{down 5}{tab 6}") sleep(500) send("{space}{tab 10}") ; if online. Move to "use start full screen", toggle it and (improves reliability) return cursor to "find a setting" search box. Else WinActivate("Settings") send("{tab}{down 5}{tab 6}") sleep(500) send("{space}{tab 6}") ; if offline. Move to "use start full screen", toggle it and (improves reliability) return cursor to "find a setting" search box. EndIf ; END https://www.autoitscript.com/forum/topic/1353-check-if-a-computer-is-online/ ; ; MouseClick("left", 379, 490, 1, 0) ; Toggle "use start full screen". Autoitv3 Window Info MouseClick Coords are 23px north. If y=467 use y=490 Sleep(500) ; Msgbox(0,"Operation halted","Continue?") ; PAUSE FOR DEBUG ; WinClose("[CLASS:ApplicationFrameWindow]", "") ; Send("{LWIN 2}") ; OPEN AND CLOSE THE START MENU Send("{LWIN}") ; OPEN START MENU sleep(500) Send("{LWIN}") ; CLOSE START MENU Sleep(1000) ; Run(@ComSpec & " /c start ms-settings:personalization-start", "", @SW_SHOWMINIMIZED) ; Sleep(500) ; WinWaitActive ("Settings") ; WinWaitActive ("[CLASS:ApplicationFrameInputSinkWindow]", "") ; ; BEGIN https://www.autoitscript.com/forum/topic/1353-check-if-a-computer-is-online/ $Computer = "8.8.8.8" AutoItSetOption ("SendKeyDelay" , "125") ;was 125, 55, 500 If RunWait("ping.exe -n 1 " & $Computer, "", @SW_HIDE) == 0 Then WinActivate("Settings") sleep(500) send("{tab 7}") ; if online. Move to "use start full screen", sleep(500) send("{space}{tab 10}") ; if online. Toggle "use start full screen" and (improves reliability) return cursor to "find a setting" search box. Else WinActivate("Settings") sleep(500) send("{tab 7}") ; if offline. Move to "use start full screen", sleep(500) send("{space}{tab 6}") ; if offline. Toggle "use start full screen" and (improves reliability) return cursor to "find a setting" search box. EndIf ; END https://www.autoitscript.com/forum/topic/1353-check-if-a-computer-is-online/ ; ; MouseClick("left", 379, 490, 1, 0) ; Toggle "use start full screen". Autoitv3 Window Info MouseClick Coords are 23px north. If y=467 use y=490 Sleep(500) ; Msgbox(0,"Operation halted","Continue?") ; PAUSE FOR DEBUG WinClose("[CLASS:ApplicationFrameWindow]", "") ; end restore blank icons on start menu Exit
    • By DavidFromLafayette
      My company is moving from WIN7 to WIN10, I have had a script that runs in the middle of the night, when the computer is locked, to open an Excel spreadsheet, read a few cells, and generate an email.  This has worked fine under WIN7, when I try to run under WIN10 it freezes when it gets to a line to handle an array.  When I run without the computer locked the script runs as expected.  After doing a lot of investigating, it looks like the following line reads a "0" from the Excel file instead of a text string, only when the computer is locked.
      Any ideas?
      $Driver1 = _Excel_RangeRead($oWorkbook, "Template", "H12")
      This is how I am opening the Excel file:
      Local $oExcel = _Excel_Open(False)
      Sleep(10000)
      $oWorkbook = _Excel_BookOpen($oExcel, $sFilePath, True, False)
    • By Simpel
      Hi,
      at work we changed now from windows 7 to windows 10. Suddenly this command _GUICtrlListView_GetHotItem() isn't working anymore for me. When I drag&drop a listviewitem it always returns -1.
      Here is the script that worked with WIN7:
      #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <Misc.au3> Local $aArray_Base[5][2] = [["0 - 0", "0 - 1"], ["1 - 0", "1 - 1"], ["2 - 0", "2 - 1"], ["3 - 0", "3 - 1"], ["4 - 0", "4 - 1"]] GUICreate("listview", 220, 200) Global $g_idListView = GUICtrlCreateListView("", 10, 10, 200, 180) _GUICtrlListView_AddColumn($g_idListView, "Col 1", 100) _GUICtrlListView_AddColumn($g_idListView, "Col 2", 100) _GUICtrlListView_AddArray($g_idListView, $aArray_Base) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYDOWN _Arrange_List() EndSwitch WEnd Func _Arrange_List() Local $iSelected = _GUICtrlListView_GetSelectionMark($g_idListView) If $iSelected = -1 Then Return While _IsPressed(1) WEnd Local $iDropped = _GUICtrlListView_GetHotItem($g_idListView) ConsoleWrite("GetHotItem: " & $iDropped & @CRLF) If $iDropped > -1 Then _GUICtrlListView_BeginUpdate($g_idListView) If $iSelected < $iDropped Then _GUICtrlListView_InsertItem($g_idListView, "", $iDropped + 1) _GUICtrlListView_SetItemText($g_idListView, $iDropped +1, _GUICtrlListView_GetItemTextString($g_idListView, $iSelected), -1) _GUICtrlListView_DeleteItem($g_idListView, $iSelected) ElseIf $iSelected > $iDropped Then _GUICtrlListView_InsertItem($g_idListView, "", $iDropped) _GUICtrlListView_SetItemText($g_idListView, $iDropped, _GUICtrlListView_GetItemTextString($g_idListView, $iSelected + 1), -1) _GUICtrlListView_DeleteItem($g_idListView, $iSelected + 1) EndIf _GUICtrlListView_SetItemSelected($g_idListView, $iDropped) _GUICtrlListView_SetSelectionMark($g_idListView, $iDropped) _GUICtrlListView_EndUpdate($g_idListView) EndIf EndFunc Any ideas?
      Regards, Simpel
       
      P.S. If I click an item then $iDropped is returning the correct number.
    • By gahhon
      I have a application that have a function is to create a shortcut to desktop, lets say is ChromePortable.lnk.
      $iCreate = FileCreateShortcut($DIR_WA_FOLDER & '\GoogleChromePortable.exe', $DIR_SHORTCUT, $DIR_WA_FOLDER, '--kiosk "https://example.com/"') So the shortcut will be launch as kiosk mode and force to enter the specific website. However, the user is still able to right-click on the shortcut and modify the target value to remove the kiosk mode. What can I do to disable the user to editing the target value?
      So far, I had asked and tried from SuperUser for advises Disable Shortcut Target Field
      icacls "ChromePortable.lnk" /GRANT EVERYONE:RX So this will set the permission of this shortcut file to only Read & Execute only! But after I set it, the user is still can modify.
      Please kindly advise.
      Please note and assume that user don't have Administration account or etc, that should be only have 1 account to logon to the computer.
       
      EDIT:
      I must disable inheritance to remove all others permissions like SYSTEM, ADMINISTRATORS, etc. Then only GRANT everyone for READ & EXECUTE only.
      But still the user can go to edit the permissions tho. Any advise?
    • By ur
      When I compiled my script or any script to exe using 32 bit compiler and ran on 32 bit machine, I am getting below error.
       

       
      But it is 32 bit only.
       
      And, for testing, I disabled smart screen also, but same issue.
      Please suggest.
       
×
×
  • Create New...