Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Confirmation Dialog Pauses Macro
I am writing a macro that performs administrative tasks on a web application running in IE7 on Vista. The web application uses a confirmation dialog box ("Ok" or "Cancel"), and I would like the macro to be able to select "OK." I tried every method I could think of including simulating key strokes, mouse clicks, and directly interacting with the dialog's class, but it appears as if the macro is paused as soon as the dialog appears, and my commands to interact with it only execute after I have manually clicked through the dialog. Is anybody aware of this issue, or a potential solution? Is Vista or IE7 trying to prevent security vulerabilities? Thanks in advance.

What is the function in the macro that waits? If it is el.Click, try to replace it to el.Mouse(1).
This function clicks the html element without the mouse. It works like Htm.Click, but does not wait while the web page is processing the click. Useful, for example, when the web page displays a dialog or message box. With Htm.Click, the macro would wait until the user closes it. With this function, the macro does not wait, and itself can populate/close the dialog box.

Member function Htm.ClickAsync. Create it using menu File -> New -> New Member Function.
Copy      Help
;Clicks the element without waiting.
;Note: The autodelay (spe) of the caller is applied.

;;clicks a link that displays a message box "VBScript", and closes the message box
;int w1=win("Internet Explorer" "IEFrame")
;act w1
;Htm el=htm("A" "msgbox" "" w1 0 0 0x21)
;int w2=wait(10 WV "VBScript")
;clo w2

if(!el) end ES_INIT

if(CoMarshalInterThreadInterfaceInStream(uuidof(MSHTML.IHTMLElement) el +&_i)) end ES_FAILED
__Handle ev=CreateEvent(0 0 0 0)
mac "__htm_clickasync" "" _i ev
wait 30 H ev; err end _error
wait -2

Also create this function. Create it using menu File -> New -> New Function.
Function __htm_clickasync
Copy      Help
function is ev

Htm el
CoGetInterfaceAndReleaseStream(+is uuidof(MSHTML.IHTMLElement) &el)
SetEvent ev
err out "Htm.ClickAsync failed: %s" _error.description
This works great. Thanks so much! Definitely not a solution I would have readily achieved on my own.

Forum Jump:

Users browsing this thread: 1 Guest(s)