Sign in to follow this  
Followers 0
jdelaney

Suppress/consume IE confirmation messages

2 posts in this topic

#1 ·  Posted (edited)

Is there a way to suppress/consume an IE confirmation messages?

When I click a <label> element on our internal website, a confirmation message is produced asking for confirmation from the user to delete the record. This message is modal, so until I manually close the message, my script is paused.

Edit: Or, is there a way to pass an IE dom object to another script, so it may perform the click?

like:

$sPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine "msgbox(1,1,IsObj ( ' & $oCell & ') )"')

Edit: Or (num2), is there a way to translate the 'uniqueid' back to the dom object through the _ie functions? $s = _IEPropertyGet($oCell,"uniqueid")

Short reproducer...notice that the msgbox will not display until you close the confirmation:

#include <IE.au3>
$oIE = _IECreate ()
$sForm = "<form>" & @CRLF & _
"<input type=""button"" value=""Press to Confirm""" & @CRLF & _
"onclick=""confirm( 'Did you fill out a 27B/6?' )"">" & @CRLF & _
"</form>"
_IEBodyWriteHTML($oIE, $sForm)
$oDoc = _IEDocGetObj($oIE)
$oCol = $oDoc.getElementsByTagName("input")
For $oInput In $oCol
 ConsoleWrite ($oInput.outerhtml & @CRLF)
 _IEAction ($oInput, "click")
 ConsoleWrite ("message from webpage was closed" & @CRLF)
Next
MsgBox(1,1,$sForm)
$oIE.quit
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

found a workaround, but not liking it...calling a second script to do the click

#include <IE.au3>
$bUseWorkaround = True
If $CmdLine[0] = 0 Then
 $oIE = _IECreate()
 $sForm = "<form>" & @CRLF & _
   "<input type=""button"" value=""Press to Confirm""" & @CRLF & _
   "onclick=""confirm( 'Did you fill out a 27B/6?' )"">" & @CRLF & _
   "</form>"
 _IEBodyWriteHTML($oIE, $sForm)
 $hIE = _IEPropertyGet($oIE, "HWND")

 If Not $bUseWorkaround Then
  $oDoc = _IEDocGetObj($oIE)
  $oCol = $oDoc.getElementsByTagName("input")
  For $oInput In $oCol
   ConsoleWrite($oInput.outerhtml & @CRLF)
   _IEAction($oInput, "click")
   ; this script will be frozen until the message from browser is closed
  Next
 Else
  Run(@AutoItExe & ' ' & @ScriptFullPath & ' ' & $hIE)
 EndIf
 MsgBox(1, 1, "no longer stalled for @autoitPID=" & @AutoItPID)
 $oIE.quit
Else
 $oIE = _IEAttach(HWnd($CmdLine[1]), "HWND")
 $oDoc = _IEDocGetObj($oIE)
 $oCol = $oDoc.getElementsByTagName("input")
 For $oInput In $oCol
  ConsoleWrite($oInput.outerhtml & @CRLF)
  _IEAction($oInput, "click")
  ; this script will be frozen until the message from browser is closed
  MsgBox(1, 1, "window closed for @autoitPID=" & @AutoItPID)
 Next
EndIf
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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  
Followers 0