Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Confirmation Dialog Pauses Macro
#3
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.
Code:
Copy      Help
;Clicks the element without waiting.
;Note: The autodelay (spe) of the caller is applied.


;EXAMPLE
;;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)
;el.ClickAsync
;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
Code:
Copy      Help
;\
function is ev

Htm el
CoGetInterfaceAndReleaseStream(+is uuidof(MSHTML.IHTMLElement) &el)
SetEvent ev
el.Click
err out "Htm.ClickAsync failed: %s" _error.description


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)